Database Reference
In-Depth Information
irectional traversals (which we'll discuss later in this chapter). Think of the re-
verse method as the expander you'd need to use to get from the current node
back to the starting node of the traversal.
Let's now implement a sample custom expander. Based on the same social network graph
used earlier in this section (see figure 8.4 ), we'll design a traversal that will again find all
movies that John's direct contacts like. But instead of using the standard Neo4j Traversal
API components, including custom evaluators, we'll use the custom PathExpander im-
plementation.
The main challenge with this query is to avoid any movies John likes, and also any movies
likedbyJohn'sfriends'friends.Todothis,we'lluseacustomexpanderwiththefollowing
characteristics:
• Follow only the IS_FRIEND_OF and WORKS_WITH relationships from the start
node (representing John).
• For all nodes visited at depth 1 (representing John's friends and work colleagues),
follow only the LIKES relationships.
Using built-in TraversalDescription methods and StandardExpander , it's not
possible to build a traversal with these characteristics. But you can implement a custom
PathExpander that does just that. The following listing shows the implementation of
such an expander.
Search WWH ::




Custom Search