问题
I want to create a graph with subgraphs (I think cluster is a synonymous - not sure ?). Someone could explain how to create this type of graph and how to export this composite graph. I readed this post Creating graph with clusters using jgrapht but i am not sure to understand this sentence "You could create a graph where each vertex is a graph by itself; edges between these vertices represent relations between these special vertices.". Does it mean that in this case verticles are relations between subgraphs. How to build this verticles? Thanks
回答1:
In JGraphT, vertices and edges are arbitrary objects: a Graph<V,E>
consists of vertices of type V
, and edges of type E
. See the wiki guide https://jgrapht.org/guide/UserOverview for details.
So you could simply define a graph where V
is also a graph: Graph<Graph<String,DefaultEdge>,DefaultEdge>
. In this example, each vertex in the graph, is a graph by itself, consisting of String vertices and DefaultEdge edges.
来源:https://stackoverflow.com/questions/59805890/how-to-create-a-graph-with-sugraph-with-jgrapht