0

This is a pretty obscure question since I don't see many people fawning over GraphStream, but does anyone know how to detect if a node exists in the graph if it has been inserted?

For example, if I write

graph.addNode(vertex1);

I get an error. If I do the same thing and write

graph.addNode(vertex1);

This is because vertex1 already exists in the graph. I can't find anything in GraphStream's documentation here and I can't find an answer anywhere I look. Any help would be much appreciated.

4

1 回答 1

0

从我在文档中看到的:

抛出: IdAlreadyInUseException - 如果启用了严格检查,则标识符已被使用。

您应该能够通过检查 的返回值来确定是否使用了标识符 getNode(vertex1.getId())

获取节点(字符串 id)

返回: 搜索到的节点,如果没有找到则返回 null。

于 2019-03-11T04:45:45.463 回答