繁体   English   中英

如何在jung库中使用DirectedSparseVertex()?

[英]How to use DirectedSparseVertex() in the jung library?

我是jung库的新手,我正在尝试创建一个新顶点,并且正在仔细地遵循jung教程(在这里: http : //jung.sourceforge.net/doc/manual.html#start )。 但是,当我尝试使用eclipse IDE时,我无法识别DirectedSparseVertex类或DirectedEdge类。 我想知道我是否缺少进口商品? 但是这是我的代码。 希望你们能提供帮助。

    import java.net.URL;
    import java.util.ArrayDeque;
    import java.util.ArrayList;
    import java.util.LinkedList;
    import java.util.PriorityQueue;
    import java.util.Queue;

    import org.jgrapht.DirectedGraph;
    import org.jgrapht.graph.DefaultEdge;
    import edu.uci.ics.jung.graph.DirectedSparseGraph;
    import edu.uci.ics.jung.graph.Graph;
    import edu.uci.ics.jung.graph.SparseGraph;
    import edu.uci.ics.jung.visualization.renderers.Renderer.Vertex;


    public class LockNodes 
    {
        public LockNodes()
        {
            Graph original = new DirectedSparseGraph();
            Vertex v1_orig = original.addVertex(new DirectedSparseVertex());
            Vertex v2_orig = original.addVertex(new DirectedSparseVertex());
            DirectedEdge e_orig = original.addEdge(new DirectedSparseEdge(v1, v2));

            Graph target = new DirectedSparseGraph();
            Vertex v1_copy = v1_orig.copy(target);
            Vertex v2_copy = v2_orig.copy(target);
            DirectedEdge e_copy = e_orig.copy(target);
        }
    }

因此其底层为红色:new DirectedSparseVertex()和DirectedEdge e_copy

您要引用的类( DirectedSparseVertexDirectedEdge )来自JUNG 1.x; 您大概正在使用新的JUNG 2.x类,该类没有用于顶点和边的类型。

(顺便说一下,请注意,从v2.1开始,JUNG的新家位于GitHub: http : //jrtom.github.io/jung/

我建议您看一下此处记录的当前Javadoc和示例: http : //jrtom.github.io/jung/javadoc/index.html

并且在本教程中(有些过时,但基于v2): http : //www.grotto-networking.com/JUNG/JUNG2-Tutorial.pdf

暂无
暂无

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

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