JAVA JUNG - 如何在Forest类中添加多个Edge

时间:2016-01-11 16:14:04

标签: java graph jung

我正在使用JUNG来构建图形,但我无法在图形中添加额外的边缘。如何在Forest类中为我的图形添加额外的边? 这是我的代码

public class BalloonLayoutDemo {

// Code borrowed from JUNG's demos

Factory<String> edgeFactory = new Factory<String>() {
    int i = 1;
    public String create() {
        System.out.println(i);
        return Integer.toString(i++);
    }
};

Forest<String, String> createTree(Forest<String, String> graph) {
    String base = "Base Node";
    graph.addEdge(edgeFactory.create(), base, "B0");
    graph.addEdge(edgeFactory.create(), base, "B1");
    graph.addEdge(edgeFactory.create(), base, "B2");
    graph.addEdge(edgeFactory.create(), base, "C1");
    graph.addEdge(edgeFactory.create(), base, "C1");
    graph.addEdge(edgeFactory.create(), base, "C1");

    return graph;
}

}

0 个答案:

没有答案