Interface Path

All Superinterfaces:
Iterable<Path.Segment>

@Immutable public interface Path extends Iterable<Path.Segment>
A Path is a directed sequence of relationships between two nodes. This generally represents a traversal or walk through a graph and maintains a direction separate from that of any relationships traversed.

It is allowed to be of size 0, meaning there are no relationships in it. In this case, it contains only a single node which is both the start and the end of the path.

     Path routeToStockholm = ..;

     // Work with each segment of the path
     for( Segment segment : routeToStockholm )
     {

     }
 
Since:
1.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    A segment combines a relationship in a path with a start and end node that describe the traversal direction for that relationship.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(Node node)
     
    boolean
    contains(Relationship relationship)
     
    end()
     
    int
     
    Create an iterable over the nodes in this path, nodes will appear in the same order as they appear in the path.
    Create an iterable over the relationships in this path.
     

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Method Details

    • start

      Node start()
      Returns:
      the start node of this path
    • end

      Node end()
      Returns:
      the end node of this path
    • length

      int length()
      Returns:
      the number of segments in this path, which will be the same as the number of relationships
    • contains

      boolean contains(Node node)
      Parameters:
      node - the node to check for
      Returns:
      true if the specified node is contained in this path
    • contains

      boolean contains(Relationship relationship)
      Parameters:
      relationship - the relationship to check for
      Returns:
      true if the specified relationship is contained in this path
    • nodes

      Iterable<Node> nodes()
      Create an iterable over the nodes in this path, nodes will appear in the same order as they appear in the path.
      Returns:
      an Iterable of all nodes in this path
    • relationships

      Iterable<Relationship> relationships()
      Create an iterable over the relationships in this path. The relationships will appear in the same order as they appear in the path.
      Returns:
      an Iterable of all relationships in this path