Database Reference
In-Depth Information
Listing 8.7. Finding Jane's direct connections who can introduce her to Ben
Youcreatethetraversalintheusualmanner,andconfigureittofollowthe KNOWS relation-
ships in any direction . You then implement the custom evaluator to determine whether
or not each visited node should be included in the results. The first step in the evaluator
is to stop the traversal if the target node (Ben, in this case) is reached —there is no
point in checking who can introduce Jane to Ben after she meets him! Next, you try to find
a direct path between the current node and the target node representing Ben . You're
using Neo4j's built-in graph algorithm to calculate the direct path (using the GraphAl-
goFactory class). If a direct path exists, that means you found a node that can introduce
Jane to Ben, so you include the current node in the result
. If there's no direct link, skip
the node and continue with the traversal
.
The main reason for this experiment is to demonstrate uniqueness, so you set it to the re-
quired NODE_GLOBAL settingusingthe uniqueness() methodofthetraversaldescrip-
 
Search WWH ::




Custom Search