Neo4j java: Traversal from multiple start points

北城余情 提交于 2020-01-25 01:43:26

问题


my task in Neo4j 2.0 embedded is to find the paths from multiple nodes to the root of the tree, in which all nodes are located.

Thus, if we assume I have start nodes A, B, and C, I'd like to find paths

A-->...-->root
B-->...-->root
C-->...-->root

For this task, I defined a TraversalDescription which works just fine when applied to each of the start nodes individually. Now I saw that the TraversalDescription's traverse method can not only take one start node but multiple. So I put all my start nodes into an array and passed this array to the traverse method like this:

Node[] startNodes = new Node[3];
startNodes[0] = node1;
...
Traverser traverse = td.traverse(startNodes);
for (Path p : traverse)
  System.out.println(p);

Here I expected to get all the paths back I sketched above. However, I only seem to get the path for the first element in the start node array, i.e. only one path although there exists one different path for each start node.

Now my question is: What is wrong? My intention of how the method should work or am I just using it incorrectly?

Thank you very much for answers, ideas and hints!


回答1:


How does your full traversal description look like? I'm guessing you're using the wrong uniqueness setting. The default is NODE_GLOBAL, which can only allow the traversal to visit any node once. I would recommend using use NODE_PATH.



来源:https://stackoverflow.com/questions/21514056/neo4j-java-traversal-from-multiple-start-points

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!