From: Georg H. <geo...@go...> - 2012-11-19 23:38:49
|
i use this: public static <V,E> void removeAllEdges(Graph<V, E> graph) { LinkedList<E> copy = new LinkedList<E>(); for (E e : graph.edgeSet()) { copy.add(e); } graph.removeAllEdges(copy); } public static <V,E> void clearGraph(Graph<V, E> graph) { removeAllEdges(graph); removeAllVertices(graph); } public static <V,E> void removeAllVertices(Graph<V, E> graph) { LinkedList<V> copy = new LinkedList<V>(); for (V v : graph.vertexSet()) { copy.add(v); } graph.removeAllVertices(copy); } On 20 November 2012 00:23, Alex Moir <am...@di...> wrote: > Does anyone know a way to reset an entire graph? I tried the following > methods and in all cases I got a ConcurrentModificationException…**** > > ** ** > > Attempt #1**** > > graph.removeAllEdges( graph.edgeSet() );**** > > graph.removeAllVertices( graph.vertexSet() );**** > > ** ** > > Attempt #2**** > > Set<RelationshipEdge> allEdges = graph.edgeSet();**** > > for ( RelationshipEdge aEdge : allEdges )**** > > { **** > > graph.removeEdge( aEdge );**** > > }**** > > ** ** > > Attempt #3**** > > Set<RelationshipEdge> allEdges = graph.edgeSet();**** > > allEdges.clear();**** > > ** ** > > ** ** > > Thanks,**** > > Alex**** > > > ------------------------------------------------------------------------------ > Monitor your physical, virtual and cloud infrastructure from a single > web console. Get in-depth insight into apps, servers, databases, vmware, > SAP, cloud infrastructure, etc. Download 30-day Free Trial. > Pricing starts from $795 for 25 servers or applications! > http://p.sf.net/sfu/zoho_dev2dev_nov > _______________________________________________ > jgrapht-users mailing list > jgr...@li... > https://lists.sourceforge.net/lists/listinfo/jgrapht-users > > |