[Neo] Traversal

Sumanth Thikka sumanth at truesparrow.com
Thu Feb 25 17:15:42 CET 2010


A doubt regarding traverser.

I created a network with 8 nodes and relations between the nodes are:

node1 -> node2
node1 -> node4
node1 -> node6
node1 -> node3
node1 -> node7
node2 -> node3
node2 -> node8
node4 -> node5
node6 -> node7
node3 -> node8

node1, node3, node5, node7and node8 have the name property as "Sumanth"

Traversal parameters are :
traversalOrder = Traverser::Order::DEPTH_FIRST
stopEvaluator = StopEvaluator::END_OF_NETWORK
returnableEvaluator = ReturnableEvaluator.when { |curr_pos| curr_pos.depth
== 2 && curr_pos.currentNode().getProperty("name")=="Sumanth"}
relationshipType = DynamicRelationshipType.withName("KNOWS")
direction= Direction::OUTGOING

traverser  =
node1.traverse(traversalOrder, stopEvaluator, returnableEvaluator ,
relationshipType, direction)

I was expecting the traverser to contain nodes node3, node5, node7and node8
as they are at depth 2 and having the name property as Sumanth. But it was
only one node i.e., node8 in the output.

My assumptions were,
returnableEvaluator consists of depth and name property conditions, which
are satisfied by node3, node5, node7and node8.
stopEvaluator is END_OF_NETWORK, so it should traverse the complete

Please help me understand better about traversal mechanism and how, what are
returned from the traverser.

Thank you,

More information about the User mailing list