Database Reference
In-Depth Information
collecting information about the current state of traversal, such as all nodes traversed, all
relationships traversed, the path starting node, the path ending node, and so on. Table 4.1
lists the methods that are available from the Path interface.
Table 4.1. The methods defined on the org.neo4j.graphdb.Path interface
Method signature
Description
Starting node of the path, not to be confused with the start-
ing node of the relationship
Node startNode();
Ending node of the path, which is the current node of the
traversal, not to be confused with the ending node of the re-
lationship
Node endNode();
Relationship lastRelationship();
Last relationship traversed
All relationships traversed until the current node, in tra-
versal order
Iterable<Relationship> relationships();
Iterable<Node> nodes();
All nodes in the path, in traversal order
Returns the length of the path, which is actually the number
of relationships traversed (or the number of nodes minus
one)
int length();
Note
It'simportant nottoconfuse the path'sstarting andending nodeswith the starting andend-
ing nodes of a relationship. Relationship starting and ending nodes depend on the direction
of the relationship. Path starting and ending nodes depend on the traversal order. As Neo4j
allows you to traverse relationships in any direction, this can sometimes lead to confusion
if you're new to Neo4j.
The evaluate(..) method has the return type
org.neo4j.graphdb.traversal.Evaluation , which is a Java enumeration
with four possible values. Based on the returned Evaluation , the traverser decides
whethertostop(or prune inNeo4jterminology) orcontinuewiththetraversal. Inaddition,
the returned Evaluation is used to determine whether to keep the current node in the
result ( include ) or to discard it ( exclude ). A combination of these two variables defines the
four values of the Evaluation enumeration. Table 4.2 explains the different Evalu-
ation values.
 
Search WWH ::




Custom Search