Database Reference
In-Depth Information
tion builder
. Finally, start the traversal from the node representing Jane and return all
collected nodes
.
If you run the traversal and output the result to the console, you'll see a single result:
John
Youcanconfirm,bylookingatthegraphin
figure 8.5
,thatJohnistheonlypersoninJane's
network who can introduce her to Ben.
So far, so good. Let's expand this experiment to the
NODE_PATH
uniqueness setting.
8.3.2. NODE_PATH uniqueness
The
NODE_PATH
uniqueness setting specifies that no path from the starting node to the
current node can be traversed twice. Multiple visits to the same node are allowed, but only
if they belong to different paths.
Let's update the code in
listing 8.7
by changing the uniqueness for the traversal to
NODE_PATH
, and, keeping all other traversal settings exactly the same, run the query
again.Thecodewilllookverysimilar,asthefollowinglistingshows.Aportionofthecode
has been omitted for clarity.
Listing 8.8. Making connections using NODE_PATH uniqueness