Graphs is composed by vertices and edges. We can look at Internet as a graph, which webpage are vertices and hyperlinks are edges.
Why doesn't the Java Collections API include a Graph implementation?
I don’t know why there is no graph library within the JDK , but I guess Sun decided to leave this to developers, since most applications that require graphs also require very unique implementations. Also as graphs can have so many different forms and flavours with wildly different characteristics, a general Graph might not turn out to be very useful. But we can use Graph libraries like:JGraphT
0 Graph Types
1) Unconnected graph and connected graph(非连通图和连通图)
2) undirected graph and directed graph(无向图和有向图)
3) graph with cycles and graph without cycles(有环图和无环图)
graph with cycles: a path that ends up where it started. Like the following figure, the path B-C-D-B forms a cycle. (Notice that A-B-C-A is not a cycle because you can’t go from C to A.).