getNode() and contains() inconsistency
Posted: 15 Apr 2014 14:56
Hi, I'm trying to create my first plugin but I encountered a strange problem. I want to temporarily remove some nodes from graph, save them to a list, do something with the graph and finally take them back to the graph. Here is a simplified code which shows the problem.
The result of this part of code is following
And my question is: why the getNode() method returns null while the contains() method confirms presence of the node in the graph (and even the addNode() method returns true, which means the node was succesfully added).
Thank you for any response.
Code: Select all
UndirectedGraph g1 = gm.getUndirectedGraph();
List<Node> list = new ArrayList<Node>();
Node a = g1.getNode(24);
Node b = g1.getNode(25);
list.add(a);
g1.removeNode(a);
list.add(b);
g1.removeNode(b);
for (Node nodeToRestore : list) {
g1.addNode(nodeToRestore);
System.out.println(nodeToRestore.getId());
System.out.println(g1.contains(nodeToRestore));
System.out.println(g1.getNode(nodeToRestore.getId()));
}
Code: Select all
24
true
null
25
true
null
Thank you for any response.