> Cool didn't thought about that... And the order of relationships() is
> the order I want different Relationship should be traversed right?
>
>
A traverser will try to go to all of these relationships on each node it
gets to and order isn't guaranteed. However you can control that order so
that for each node it traverses it first visits its all relationships of
type A, then all its relationships of type B a.s.o. What you cannot do out
of the box is to say that from the start node it should traverse
relationships of type A and then when it has gotten to those nodes traverse
relationships of type B. An example:

  (1)--A-->(2)--B-->(3)
    \
     B
      v
      (4)--A-->(5)

  with: Traversal.description().relationships(A).relationships(B)

Will still return 1,2,3,4,5 (order not guaranteed). You can achieve this
behaviour by implementing your own RelationshipExpander, but that's a little
more advanced. If you would like to force the traversal down a very defined
path then go with the core API, like:

  for(Relationship relA : startNode.getRelationships(A)) {
      Node nodeA = relA.getOtherNode(startNode);
      for(Relationship relB : nodeA.getRelationships(B)) {
          Node nodeB = relB.getOtherNode(nodeA);
          // nodeB will be the node (3) from the above example
      }
  }

I'm positive that some nice API will enter the kernel at some point, f.ex.
I'm experimenting with an API like this:

  for(Node node :
PipeBuilder.fromNode(startNode).into(otherNode(A)).into(otherNode(B)).nodes())
{
     // node will be (3) from the example above
  }


I hope I didn't confuse you with all this :)

Best,
Mattias

-- 
Mattias Persson, [matt...@neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com
_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to