如何在JUNG 2.0框架中复制图表? [英] How to copy a graph in JUNG 2.0 framework?

查看:116
本文介绍了如何在JUNG 2.0框架中复制图表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JUNG 1.7.6中有为此目的的函数copy()(myGraph.copy()),但是在JUNG 2.0中这个函数不再存在。我找不到任何其他可能性来创建图形对象的副本。如果有人能帮助我,我会很高兴。解决方法也不错。



非常感谢! 解决方案

p>下面用泛型代码,所以你应该用 String 来替换 V E code>图< String,String>

 图< V,E> SRC; 
图< V,E> DEST; (v v:src.getVertices())
dest.addVertex(v);

(e,src.getEdges())
dest.addEdge(e,src.getIncidentVertices(e));



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

这篇关于如何在JUNG 2.0框架中复制图表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆