Question

I am trying to do vertex cuts on graphs in the JUNG graph package. This is best explained by the following pictures:Before the Vertex Cut

Now, I am going to cut vertex "c1" out of the graph: After the Vertex Cut

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.

  1. How can I implement my code to keep vertices "c2" and "c3" when I cut vertex "c1"?
  2. I am using a Forest as my graph type
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top