org.neo4j.graphdb
Interface Path

 All Superinterfaces:
 Iterable<PropertyContainer>
 All Known Subinterfaces:
 TraversalBranch, WeightedPath
public interface Path extends Iterable<PropertyContainer>
Represents a path in the graph. A path starts with a node followed by pairs ofRelationship
andNode
objects. The shortest path is of length 0. Such a path contains only one node and no relationships. During a traversalPath
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 viaendNode()
.


Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description Node
endNode()
Returns the end node of this path.Iterator<PropertyContainer>
iterator()
Iterates through both theNode
s andRelationship
s of this path in order.Relationship
lastRelationship()
Returns the lastRelationship
in this path.int
length()
Returns the length of this path.Iterable<Node>
nodes()
Returns all the nodes in this path starting from the start node going forward towards the end node.Iterable<Relationship>
relationships()
Returns all the relationships in between the nodes which this path consists of.Iterable<Node>
reverseNodes()
Returns all the nodes in this path in reversed order, i.e.Iterable<Relationship>
reverseRelationships()
Returns all the relationships in between the nodes which this path consists of in reverse order, i.e.Node
startNode()
Returns the start node of this path.String
toString()
Returns a natural string representation of this path.
Methods inherited from interface java.lang.Iterable
forEach, spliterator




Method Detail

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
Iterable<Node> 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
Iterable<Node> 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.

iterator
Iterator<PropertyContainer> 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). Specified by:
iterator
in interfaceIterable<PropertyContainer>
 See Also:
Iterable.iterator()

