简体   繁体   English

在Jung中克隆图形的最佳方法是什么?

[英]what's the best way to clone a graph in Jung?

the title pretty much sums it all - 标题几乎概括了所有内容-

I'm using Jung as my graph model and I want to clone my graphs. 我正在使用Jung作为我的图形模型,我想克隆我的图形。 is there a best-practice for this? 有最佳实践吗?

thanks 谢谢

You could do a simple copy of vertices & edges: 您可以制作顶点和边的简单副本:

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));

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/ 会创建一个新的图,但其中的对象将通过引用传递,因此您可以使用此克隆库https://code.google.com/p/cloning/

and do a deep copy: 并进行深层复制:

Cloner cloner = new Cloner();
Graph<V, E> clonedGraph = cloner.deepClone(graph);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM