Package org.neo4j.graphdb
Interface Path
- All Known Subinterfaces:
TraversalBranch
,WeightedPath
Represents a path in the graph. A path starts with a node followed by
pairs of
Relationship
and Node
objects. The shortest path
is of length 0. Such a path contains only one node and no relationships.
During a traversal Path
instances are emitted where the current
position of the traverser is represented by each such path. The current
node in such a traversal is reached via endNode()
.-
Method Summary
Modifier and TypeMethodDescriptionendNode()
Returns the end node of this path.iterator()
Iterates through both theNode
s andRelationship
s of this path in order.Returns the lastRelationship
in this path.int
length()
Returns the length of this path.nodes()
Returns all the nodes in this path starting from the start node going forward towards the end node.Returns all the relationships in between the nodes which this path consists of.Returns all the nodes in this path in reversed order, i.e.Returns all the relationships in between the nodes which this path consists of in reverse order, i.e.Returns the start node of this path.toString()
Returns a natural string representation of this path.
-
Method Details
-
startNode
Node startNode()Returns the start node of this path. It's also the first node returned from thenodes()
iterable.- Returns:
- the start node.
-
endNode
Node endNode()Returns the end node of this path. It's also the last node returned fromnodes()
iterable. If thelength()
of this path is 0 the end node returned by this method is the same as the start node. If a path is emitted from a traverser the end node is the current node where the traverser is at the moment.- Returns:
- the end node.
-
lastRelationship
Relationship lastRelationship()Returns the lastRelationship
in this path.- Returns:
- the last
Relationship
in this path, ornull
if this path contains noRelationship
s.
-
relationships
Iterable<Relationship> relationships()Returns all the relationships in between the nodes which this path consists of. For a path withlength()
0 this will be an emptyIterable
.- Returns:
- the relationships in this path.
-
reverseRelationships
Iterable<Relationship> reverseRelationships()Returns all the relationships in between the nodes which this path consists of in reverse order, i.e. starting from thelastRelationship()
going backwards towards the first relationship in the path. For a path withlength()
0 this will be an emptyIterable
.- Returns:
- the relationships in this path in reverse order.
-
nodes
Returns all the nodes in this path starting from the start node going forward towards the end node. The first node is the same asstartNode()
and the last node is the same asendNode()
. In between those nodes there can be an arbitrary number of nodes. The shortest path possible is just one node, where also the the start node is the same as the end node.- Returns:
- the nodes in this path.
-
reverseNodes
Returns all the nodes in this path in reversed order, i.e. starting from the end node going backwards instead of from the start node going forwards. The first node is the same asendNode()
and the last node is the same asstartNode()
. In between those nodes there can be an arbitrary number of nodes. The shortest path possible is just one node, where also the the start node is the same as the end node.- Returns:
- the nodes in this path starting from the end node going backwards towards the start node.
-
length
int length()Returns the length of this path. That is the number of relationships (which is the same as the number of nodes minus one). The shortest path possible is of length 0.- Returns:
- the length (i.e. the number of relationships) in the path.
-
toString
String toString()Returns a natural string representation of this path. The string representation shows the nodes with relationships (and their directions) in between them.- Returns:
- A string representation of the path.
-
iterator
Iterates through both theNode
s andRelationship
s of this path in order. InterleavingNode
s withRelationship
s, starting and ending with aNode
(thestartNode()
andendNode()
respectively).- See Also:
-