问题
I am trying to do vertex cuts on graphs in the JUNG graph package. This is best explained by the following pictures:
Now, I am going to cut vertex "c1" out of the graph:
As you can see vertex "c1" has been removed from the graph, but so have the vertices "c2" and "c3"
I want the vertices "c2" and "c3" to stay in the graph when I cut vertex "c1".
I am using the removeVertex(V vertex)
function to remove vertex "c1" from the graph.
- How can I implement my code to keep vertices "c2" and "c3" when I cut vertex "c1"?
- I am using a Forest as my graph type
回答1:
You could take a look at DelegateForest
and its removeVertex(vertex,boolean) command which lets you specify whether or not to remove the entire subtree rooted in your vertex
来源:https://stackoverflow.com/questions/12966684/java-jung-vertex-cuts-in-graphs