Database Reference
In-Depth Information
You're not limited to one starting point in each direction. Bidirectional traversal allows for
multiple starting pointsforbothdirections. Tousethat feature, all youhavetodoisusethe
overloaded BidirectionalTraversalDescription.traverse method:
BidirectionalTraversalDescription.traverse( Iterable<Node> start,
Iterable<Node> end )
All this makes bidirectional traversal a very powerful tool. In a few lines of code, you can
write fast traversals to find patterns based on a number of fixed nodes, such as finding all
users who know each of the users from a given set. Although bidirectional traversals are a
bit more difficult to set up, they offer better performance and use less memory than stand-
ard traversal, especially for longer paths.
8.5. Summary
Traversal is a very powerful way to query graph data, and in this chapter you learned ad-
vanced concepts and techniques that can help you write fast and efficient traversals.
Usingcorrecttraversalorderingcanmakeahugedifferenceinthespeedandmemoryfoot-
printofatraversal,especiallyonlargegraphdatasets.In section 8.1 yousawhowdifferent
traversals benefit from common depth-first and breadth-first branch ordering strategies.
You also learned about the key concept of relationship expansion. You've seen a standard
expander in action, which is good for all typical traversal use cases. But for more specific
scenarios, we demonstrated how you can order relationships with an ordered expander and
also how you can implement custom relationship expanders, taking full advantage of the
power of Neo4j's flexible Traversal API.
Theuniquenessofvisitednodesandrelationshipswasthenextadvancedtraversaltopicwe
covered. You learned how to make sure you visited each node or relationship only once
duringthetraversal.Wealsoillustratedhowtousedifferentuniquenessconstraintstosolve
some queries.
Search WWH ::




Custom Search