A simple double for-loop would suffice perhaps:

   for ( Relationship rel1 : startNode.getRelationships( relType1, dir1 ) )
{
       Node node1 = rel1.getOtherNode( startNode );
       for ( Relationship rel2 : node1.getRelationships( relType2, dir2 ) )
{
           Node node2 = rel2.getOtherNode( node1 );
           // Here you've got startNode,rel1,node1,rel2,node2 and it's just
           // to pick properties from them.
       }
   }

2011/7/22 sulabh choudhury <[email protected]>

> Hi,
>
> I am trying to create a traverser and I am stuck.
> So my code takes in a startNode, 2 relationshiptypes and 2 directions.
> It will starting from startNode go to nodes with rel1 in dir1 and from all
> those nodes to rel2,dir2.
> The code below (in SCALA) works fine and I get the expected nodes.
>
> The issue is, along with the nodes I also need to get properties from the
> relationships. So all my relationshiptypes have certain properties (key,
> value), what I want is to get a particular property from rel1 and rel2. How
> do I do that?
>
>
>  def traverser(node: Node, rel1: RelationshipType, rel2: RelationshipType,
> dir1: Direction, dir2: Direction) = {
>
>   val q1 =  node.traverse(Order.BREADTH_FIRST, StopEvaluator.DEPTH_ONE,
> ReturnableEvaluator.ALL_BUT_START_NODE, rel1, dir1).iterator()
>
>    while(q1.hasNext){
>      val n = q1.next()
>      val q2 =
>
> n.traverse(Order.BREADTH_FIRST,StopEvaluator.DEPTH_ONE,ReturnableEvaluator.ALL_BUT_START_NODE,
> rel2, dir2).iterator()
>      while(q2.hasNext)
>           println(q2.next)
>   }
> }
> _______________________________________________
> Neo4j mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
>



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

Reply via email to