Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy a graph in JUNG 2.0 framework?

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!

like image 757
user1377963 Avatar asked May 06 '12 11:05

user1377963


1 Answers

Code below with generics, so you should replace V and E with String for your Graph<String, String>.

    Graph<V, E> src;
    Graph<V, E> dest;

    for (V v : src.getVertices())
        dest.addVertex(v);

    for (E e : src.getEdges())
        dest.addEdge(e, src.getIncidentVertices(e));
like image 192
Vadim Ponomarev Avatar answered Nov 11 '22 06:11

Vadim Ponomarev