Package 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 Summary
Modifier and TypeMethodDescriptionA convenience method fororder(BranchOrderingPolicy)
where a "preorder breadth first" selector is used.A convenience method fororder(BranchOrderingPolicy)
where a "preorder depth first" selector is used.Addsevaluator
to the list of evaluators which will control the behavior of the traversal.evaluator
(PathEvaluator evaluator) Addsevaluator
to the list of evaluators which will control the behavior of the traversal.expand
(PathExpander<?> expander) Sets thePathExpander
as the expander of relationships, discarding all previous calls torelationships(RelationshipType)
andrelationships(RelationshipType, Direction)
or any other expand method.<STATE> TraversalDescription
expand
(PathExpander<STATE> expander, InitialBranchState<STATE> initialState) Sets thePathExpander
as the expander of relationships, discarding all previous calls torelationships(RelationshipType)
andrelationships(RelationshipType, Direction)
or any other expand method.order
(BranchOrderingPolicy selector) Sets theBranchOrderingPolicy
to use.Addstype
to the list of relationship types to traverse.relationships
(RelationshipType type, Direction direction) Addstype
to the list of relationship types to traverse in the givendirection
.reverse()
Creates an identicalTraversalDescription
, although reversed in how it traverses the graph.sort
(Comparator<? super Path> comparator) Traverse from a iterable of start nodes based on all the rules and behavior in this description.Traverse from a single start node based on all the rules and behavior in this description.Traverse from a set of start nodes based on all the rules and behavior in this description.uniqueness
(UniquenessFactory uniqueness) Sets theUniquenessFactory
for creating theUniquenessFilter
to use.uniqueness
(UniquenessFactory uniqueness, Object parameter) Sets theUniquenessFactory
for creating theUniquenessFilter
to use.
-
Method Details
-
uniqueness
Sets theUniquenessFactory
for creating theUniquenessFilter
to use.- Parameters:
uniqueness
- theUniquenessFactory
the creator of the desiredUniquenessFilter
to use.- Returns:
- a new traversal description with the new modifications.
-
uniqueness
Sets theUniquenessFactory
for creating theUniquenessFilter
to use. It also accepts an extra parameter which is mandatory for certain uniquenesses.- Parameters:
uniqueness
- theUniquenessFactory
the creator of the desiredUniquenessFilter
to use.parameter
- an extra parameter which is mandatory for certain uniquenesses.- Returns:
- a new traversal description with the new modifications.
-
evaluator
Addsevaluator
to the list of evaluators which will control the behavior of the traversal. EachEvaluator
can decide whether or not to include a position in the traverser result, i.e. return it from theTraverser
iterator and also whether to continue down that path or to prune, so that the traverser won't continue further down that path. MultipleEvaluator
s can be added. For a path to be included in the result, all evaluators must agree to include it, i.e. returning eitherEvaluation.INCLUDE_AND_CONTINUE
orEvaluation.INCLUDE_AND_PRUNE
. For making the traversal continue down that path all evaluators must agree to continue from that path, i.e. returning eitherEvaluation.INCLUDE_AND_CONTINUE
orEvaluation.EXCLUDE_AND_CONTINUE
.- Parameters:
evaluator
- theEvaluator
to add to the traversal- Returns:
- a new traversal description with the new modifications.
-
evaluator
Addsevaluator
to the list of evaluators which will control the behavior of the traversal. EachPathEvaluator
can decide whether or not to include a position in the traverser result, i.e. return it from theTraverser
iterator and also whether to continue down that path or to prune, so that the traverser won't continue further down that path. MultiplePathEvaluator
s can be added. For a path to be included in the result, all evaluators must agree to include it, i.e. returning eitherEvaluation.INCLUDE_AND_CONTINUE
orEvaluation.INCLUDE_AND_PRUNE
. For making the traversal continue down that path all evaluators must agree to continue from that path, i.e. returning eitherEvaluation.INCLUDE_AND_CONTINUE
orEvaluation.EXCLUDE_AND_CONTINUE
.- Parameters:
evaluator
- thePathEvaluator
to add to the traversal- Returns:
- a new traversal description with the new modifications.
-
order
Sets theBranchOrderingPolicy
to use. ABranchSelector
is the basic decisions in the traversal of "where to go next". Examples of default implementations are "breadth first" and "depth first", which can be set with convenience methodsbreadthFirst()
anddepthFirst()
.- Parameters:
selector
- the factory which creates theBranchSelector
to use with the traversal.- Returns:
- a new traversal description with the new modifications.
-
depthFirst
TraversalDescription depthFirst()A convenience method fororder(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 fororder(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
Addstype
to the list of relationship types to traverse. There's no priority or order in which types to traverse.- Parameters:
type
- theRelationshipType
to add to the list of types to traverse.- Returns:
- a new traversal description with the new modifications.
-
relationships
Addstype
to the list of relationship types to traverse in the givendirection
. There's no priority or order in which types to traverse.- Parameters:
type
- theRelationshipType
to add to the list of types to traverse.direction
- theDirection
to traverse this type of relationship in.- Returns:
- a new traversal description with the new modifications.
-
expand
Sets thePathExpander
as the expander of relationships, discarding all previous calls torelationships(RelationshipType)
andrelationships(RelationshipType, Direction)
or any other expand method.- Parameters:
expander
- thePathExpander
to use.- Returns:
- a new traversal description with the new modifications.
-
expand
<STATE> TraversalDescription expand(PathExpander<STATE> expander, InitialBranchState<STATE> initialState) Sets thePathExpander
as the expander of relationships, discarding all previous calls torelationships(RelationshipType)
andrelationships(RelationshipType, Direction)
or any other expand method. The suppliedInitialBranchState
will provide the initial traversal branches with state values which flows down throughout the traversal and can be changed for child branches by thePathExpander
at any level.- Type Parameters:
STATE
- the type of the state object- Parameters:
expander
- thePathExpander
to use.initialState
- factory for supplying the initial traversal branches with state values potentially used by thePathExpander
.- Returns:
- a new traversal description with the new modifications.
-
sort
- Parameters:
comparator
- theComparator
to use for sorting the paths.- Returns:
- the paths from this traversal sorted according to
comparator
.
-
reverse
TraversalDescription reverse()Creates an identicalTraversalDescription
, although reversed in how it traverses the graph.- Returns:
- a new traversal description with the new modifications.
-
traverse
Traverse from a single start node based on all the rules and behavior in this description. ATraverser
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. -
traverse
Traverse from a set of start nodes based on all the rules and behavior in this description. ATraverser
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. -
traverse
Traverse from a iterable of start nodes based on all the rules and behavior in this description. ATraverser
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.
-