org.neo4j.graphdb.traversal

Interface TraversalDescription



  • public interface TraversalDescription
    Represents a description of a traversal. This interface describes the rules and behavior of a traversal. A traversal description is immutable and each method which adds or modifies the behavior returns a new instances that includes the new modification, leaving the instance which returns the new instance intact. For instance,
     TraversalDescription td = new TraversalDescriptionImpl();
     td.depthFirst();
     
    is not going to modify td. you will need to reassign td, like
     td = td.depthFirst();
     

    When all the rules and behaviors have been described the traversal is started by using traverse(Node) where a starting node is supplied. The Traverser that is returned is then used to step through the graph, and return the positions that matches the rules.

    • Method Detail

      • depthFirst

        TraversalDescription depthFirst()
        A convenience method for order(BranchOrderingPolicy) where a "preorder depth first" selector is used. Positions which are deeper than the current position will be returned before positions on the same depth. See http://en.wikipedia.org/wiki/Depth-first_search
        Returns:
        a new traversal description with the new modifications.
      • breadthFirst

        TraversalDescription breadthFirst()
        A convenience method for order(BranchOrderingPolicy) where a "preorder breadth first" selector is used. All positions with the same depth will be returned before advancing to the next depth. See http://en.wikipedia.org/wiki/Breadth-first_search
        Returns:
        a new traversal description with the new modifications.
      • relationships

        TraversalDescription relationships(RelationshipType type)
        Adds type to the list of relationship types to traverse. There's no priority or order in which types to traverse.
        Parameters:
        type - the RelationshipType to add to the list of types to traverse.
        Returns:
        a new traversal description with the new modifications.
      • relationships

        TraversalDescription relationships(RelationshipType type,
                                           Direction direction)
        Adds type to the list of relationship types to traverse in the given direction. There's no priority or order in which types to traverse.
        Parameters:
        type - the RelationshipType to add to the list of types to traverse.
        direction - the Direction to traverse this type of relationship in.
        Returns:
        a new traversal description with the new modifications.
      • traverse

        Traverser traverse(Node startNode)
        Traverse from a single start node based on all the rules and behavior in this description. A Traverser is returned which is used to step through the graph and getting results back. The traversal is not guaranteed to start before the Traverser is used.
        Parameters:
        startNode - Node to start traversing from.
        Returns:
        a Traverser used to step through the graph and to get results from.
      • traverse

        Traverser traverse(Node... startNodes)
        Traverse from a set of start nodes based on all the rules and behavior in this description. A Traverser is returned which is used to step through the graph and getting results back. The traversal is not guaranteed to start before the Traverser is used.
        Parameters:
        startNodes - Nodes to start traversing from.
        Returns:
        a Traverser used to step through the graph and to get results from.
      • traverse

        Traverser traverse(Iterable<Node> iterableStartNodes)
        Traverse from a iterable of start nodes based on all the rules and behavior in this description. A Traverser is returned which is used to step through the graph and getting results back. The traversal is not guaranteed to start before the Traverser is used.
        Parameters:
        iterableStartNodes - Nodes to start traversing from.
        Returns:
        a Traverser used to step through the graph and to get results from.

Copyright © 2002–2017 The Neo4j Graph Database Project. All rights reserved.