0

我在一个项目中使用 GraphStream,我的问题是我想检索连接组件的列表,但我只能得到它们的计数或最好的它们的 Id。

我已经尝试过这段代码,但它没有返回任何内容:

ConnectedComponents cc = new ConnectedComponents();
cc.init(graph);
System.out.println("List of Connected Components :");
for(ConnectedComponent conn : cc) {
   System.out.println("Component " + conn.id + " :");
   System.out.println("--------------");
   for(Node n : conn.getEachNode()) {
      Object[] attr = n.getAttribute("xy");
      Double x = (Double) attr[0];
      Double y = (Double) attr[1];
      System.out.println(x + " , " + y);
    }
}

节点具有属性“xy”,其中包含存储为 Double[] 的坐标。

我做错了什么?我该如何解决?

4

1 回答 1

1

ConnectedComponents已在2015-12-15的提交中重写。检索组件内容时出现问题。

如果你没有使用 GraphStream 的 git 版本,也许你应该尝试一下。

于 2016-03-25T14:38:40.880 回答