Dear jgrapht users,

 

In my problem, I want to traverse the graph to find a certain vertex, then delete the vertex accompanied with all the edges connected to it. Then I will traverse the remained graph again, find another vertex by some special rules, deleted the vertex and all the connected edges…

 

However, when I translate the procedure into JAVA codes, I always receive the same error message:

 

java.util.ConcurrentModificationException

         at java.util.ArrayList$Itr.checkForComodification(Unknown Source)

         at java.util.ArrayList$Itr.next(Unknown Source)

         at java.util.Collections$UnmodifiableCollection$1.next(Unknown Source)

         at org.jgrapht.graph.AbstractGraph.removeAllEdges(AbstractGraph.java:89)

         ……

 

The following is my JAVA code related to this:

 

                            for (Node myNode : myNodeList) {

                                   // Some codes to find the certain node, the name is myNode

                                   // Some operations

                                   myGraph.removeAllEdges(myGraph.edgesOf(myNode));

                                   myGraph.removeVertex(myNode);

                            }

 

This problem has bothered me for quite a long time, many thanks in advance!

 

Best Regards

 

Zhigang Wu