Path (Neo4j Community 1.8.RC1 API)
Date: 2012-09-07

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Neo4j Community
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.neo4j.graphdb
Interface Path

All Superinterfaces:
  Iterable<PropertyContainer>

All Known Subinterfaces:
  TraversalBranch, WeightedPath

All Known Implementing Classes:
  BidirectionalTraversalBranchPath, ExtendedPath

    public interface Path

extends Iterable<PropertyContainer>

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
`Node` | `endNode()` Returns the end node of this path.
`Iterator<PropertyContainer>` | `iterator()` Iterates through both the `Node`s and `Relationship`s of this path in order.
`Relationship` | `lastRelationship()` Returns the last `Relationship` 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.

Method Detail

### startNode

    Node startNode()

  Returns the start node of this path. It's also the first node returned from the `nodes()` iterable.

  Returns:
    the start node.

### endNode

    Node endNode()

  Returns the end node of this path. It's also the last node returned from `nodes()` iterable. If the `length()` 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 last `Relationship` in this path.

  Returns:
    the last `Relationship` in this path, or `null` if this path contains no `Relationship`s.

### relationships

    Iterable<Relationship> relationships()

  Returns all the relationships in between the nodes which this path consists of. For a path with `length()` 0 this will be an empty `Iterable`.

  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 the `lastRelationship()` going backwards towards the first relationship in the path. For a path with `length()` 0 this will be an empty `Iterable`.

  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 as `startNode()` and the last node is the same as `endNode()`. 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 as `endNode()` and the last node is the same as `startNode()`. 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.

  Overrides:
    `toString` in class `Object`
  Returns:
    A string representation of the path.

### iterator

    Iterator<PropertyContainer> iterator()

  Iterates through both the `Node`s and `Relationship`s of this path in order. Interleaving `Node`s with `Relationship`s, starting and ending with a `Node` (the `startNode()` and `endNode()` respectively).

  Specified by:
    `iterator` in interface `Iterable<PropertyContainer>`
  See Also:
    `Iterable.iterator()`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Neo4j Community
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2012 The Neo4j Graph Database Project. All Rights Reserved.