in JUNG 1.7.6 there was the function copy() for this purpose (myGraph.copy()), but in JUNG 2.0 this function does not exist anymore. I could not find any other possibility to create a copy of a graph object. I would be very glad if someone could help me. A workaround would be nice, too.
Thanks a lot!
Code below with generics, so you should replace
V
andE
withString
for yourGraph<String, String>
.You can copy the graph manually by iterating over all vertices and all edges and adding them to a new graph. See getVertices() in the API
You could do a simple copy of vertices & edges, that would create a new Graph, but the objects inside will be passed by reference so you could use this cloning library https://code.google.com/p/cloning/
and do a deep copy: