Neo4j Traversers are built by the Traversal
class under the hood, whose configuration is made available as TraversalDescription
via the GraphDatabaseService
(in Neo4j 2.0).
I believe that there are still legacy, deprecated implementations in the code of Neo4J.
Traversal comes in 2 types:
1. Unidirectional traversal
Instantiate by calling:
TraversalDescription traversalDescription = graphDatabaseService.traversalDescription()
The obtained traversalDescription is actually a builder pattern allowing you to set different properties for your traversal. See the API at http://api.neo4j.org/current/org/neo4j/graphdb/traversal/TraversalDescription.html.
2. Bi-directional traversal
A bi-directional traversal is instantiated using
BidirectionalTraversalDescription bidirectionalTraversalDescription =
graphDatabaseService.bidirectionalTraversalDescription()
This TraversalDescription has a start and endside which are actually two different TraversalDescriptions and can be instantiated using a similar building pattern as the uni-directional traversal.
e.g.
graphDatabaseService
.bidirectionalTraversalDescription()
.startSide(graphDatabaseService
.traversalDescription()
.depthFirst()
.uniqueness(Uniqueness.NODE_PATH))
.endSide(graphDatabaseService
.traversalDescription()
.depthFirst()
.uniqueness(Uniqueness.NODE_PATH))
I used Scala code to show the instantiations, I hope it is clear.
GraphDatabaseService.(biDirectional)TraversalDescription()
– Kerbela