Database Reference
In-Depth Information
Listing 8.6. Finding all movies John's friends like using a custom expander
Thefirststepistoconfigurewhichrelationshipstofollowateachdepth .Themappings
aretofollowthe IS_FRIEND_OF and WORKS_WITH relationshipsdirectlyfromthestart-
ing node (depth 0) and the LIKES relationships from nodes at depth 1. The key point in
the traversal implementation is to configure the traversal description to use the custom ex-
pander
. As you're only interested in the nodes up to depth 2, you use the atDepth
evaluator to stop the traversal at the specified depth
. Finally, you start the traversal
from the node representing John and iterate through the results in the usual manner
.
Whenyouexecute thetraversal, theconsole outputwill display theexpected movies, Alien
and Fargo , which are liked by John's direct contacts. The full demo, including all the code
in this section, is available as part of this topic's sample code.
ThenextadvancedNeo4jTraversalAPItopicwe'llcoverisuniqueness,soreadontolearn
how to control how many times the traverser can visit any node or relationship.
Search WWH ::




Custom Search