public class Traversal extends Object
traversal()
for creating a new
TraversalDescription
, methods for creating new
TraversalBranch
instances and more.Modifier and Type | Class and Description |
---|---|
static class |
Traversal.DefaultPathDescriptor<T extends Path>
The default
Traversal.PathDescriptor used in common toString()
representations in classes implementing Path . |
static interface |
Traversal.PathDescriptor<T extends Path>
Provides hooks to help build a string representation of a
Path . |
Constructor and Description |
---|
Traversal() |
Modifier and Type | Method and Description |
---|---|
static SideSelectorPolicy |
alternatingSelectorOrdering() |
static BidirectionalTraversalDescription |
bidirectionalTraversal() |
static TraversalBranch |
combineSourcePaths(TraversalBranch source,
TraversalBranch target)
Combines two
TraversalBranch s with a common
head node in order to obtain an
TraversalBranch representing a path from the start node of the
source TraversalBranch to the start node of the
target TraversalBranch . |
static String |
defaultPathToString(Path path)
TODO: This method re-binds nodes and relationships.
|
static TraversalDescription |
description()
Creates a new
TraversalDescription with default value for
everything so that it's OK to call
TraversalDescription.traverse(org.neo4j.graphdb.Node) without
modification. |
static Expander |
emptyExpander()
|
static <STATE> PathExpander<STATE> |
emptyPathExpander()
Returns an empty
PathExpander which, if not modified, will expand
all relationships when asked to expand a Node . |
static Expander |
expander(PathExpander expander) |
static Expander |
expander(RelationshipExpander expander)
Returns a
RelationshipExpander wrapped as an Expander . |
static Expander |
expanderForAllTypes()
Returns a
RelationshipExpander which expands relationships
of all types and directions. |
static Expander |
expanderForAllTypes(Direction direction)
Returns a
RelationshipExpander which expands relationships
of all types in the given direction . |
static Expander |
expanderForTypes(RelationshipType type)
Creates a new
RelationshipExpander which is set to expand
relationships with type in any direction. |
static Expander |
expanderForTypes(RelationshipType type,
Direction dir)
|
static Expander |
expanderForTypes(RelationshipType type1,
Direction dir1,
RelationshipType type2,
Direction dir2)
Creates a new
RelationshipExpander which is set to expand
relationships with two different types and directions. |
static Expander |
expanderForTypes(RelationshipType type1,
Direction dir1,
RelationshipType type2,
Direction dir2,
Object... more)
Creates a new
RelationshipExpander which is set to expand
relationships with multiple types and directions. |
static <STATE> InitialStateFactory<STATE> |
initialState(STATE initialState)
InitialStateFactory which always returns the supplied initialState . |
static SideSelectorPolicy |
levelSelectorOrdering() |
static PathDescription |
path() |
static <STATE> PathExpander<STATE> |
pathExpanderForAllTypes()
Returns a
RelationshipExpander which expands relationships
of all types and directions. |
static <STATE> PathExpander<STATE> |
pathExpanderForAllTypes(Direction direction)
Returns a
PathExpander which expands relationships
of all types in the given direction . |
static <STATE> PathExpander<STATE> |
pathExpanderForTypes(RelationshipType type)
Creates a new
PathExpander which is set to expand
relationships with type in any direction. |
static <STATE> PathExpander<STATE> |
pathExpanderForTypes(RelationshipType type,
Direction dir)
|
static <STATE> PathExpander<STATE> |
pathExpanderForTypes(RelationshipType type1,
Direction dir1,
RelationshipType type2,
Direction dir2)
Creates a new
PathExpander which is set to expand
relationships with two different types and directions. |
static <STATE> PathExpander<STATE> |
pathExpanderForTypes(RelationshipType type1,
Direction dir1,
RelationshipType type2,
Direction dir2,
Object... more)
Creates a new
PathExpander which is set to expand
relationships with multiple types and directions. |
static <T extends Path> |
pathToString(T path,
Traversal.PathDescriptor<T> builder)
Method for building a string representation of a
Path , using
the given builder . |
static BranchOrderingPolicy |
postorderBreadthFirst()
Returns a "postorder breadth first" ordering policy.
|
static BranchOrderingPolicy |
postorderDepthFirst()
Returns a "postorder depth first" ordering policy.
|
static BranchOrderingPolicy |
preorderBreadthFirst()
Returns a "preorder breadth first" ordering policy.
|
static BranchOrderingPolicy |
preorderDepthFirst()
Returns a "preorder depth first" ordering policy.
|
static BranchCollisionDetector |
shortestPathsCollisionDetector(int maxDepth) |
static String |
simplePathToString(Path path)
Returns a quite simple string representation of a
Path . |
static String |
simplePathToString(Path path,
String nodePropertyKey)
Returns a quite simple string representation of a
Path . |
static TraversalDescription |
traversal()
More convenient name than
description() when using static imports. |
static TraversalDescription |
traversal(UniquenessFactory uniqueness) |
static TraversalDescription |
traversal(UniquenessFactory uniqueness,
Object optionalUniquenessParameter) |
public static TraversalDescription description()
TraversalDescription
with default value for
everything so that it's OK to call
TraversalDescription.traverse(org.neo4j.graphdb.Node)
without
modification. But it isn't a very useful traversal, instead you should
add rules and behaviors to it before traversing.TraversalDescription
with default values.public static TraversalDescription traversal()
description()
when using static imports.
Does the same thing.description()
public static TraversalDescription traversal(UniquenessFactory uniqueness)
public static TraversalDescription traversal(UniquenessFactory uniqueness, Object optionalUniquenessParameter)
public static BidirectionalTraversalDescription bidirectionalTraversal()
public static <STATE> InitialStateFactory<STATE> initialState(STATE initialState)
InitialStateFactory
which always returns the supplied initialState
.initialState
- the initial state for a traversal branch.InitialStateFactory
which always will return the supplied
initialState
.public static Expander expanderForTypes(RelationshipType type, Direction dir)
type
- the RelationshipType
to expand.dir
- the Direction
to expand.RelationshipExpander
.public static <STATE> PathExpander<STATE> pathExpanderForTypes(RelationshipType type, Direction dir)
type
- the RelationshipType
to expand.dir
- the Direction
to expand.PathExpander
.public static Expander expanderForTypes(RelationshipType type)
RelationshipExpander
which is set to expand
relationships with type
in any direction.type
- the RelationshipType
to expand.RelationshipExpander
.public static <STATE> PathExpander<STATE> pathExpanderForTypes(RelationshipType type)
PathExpander
which is set to expand
relationships with type
in any direction.type
- the RelationshipType
to expand.PathExpander
.public static Expander emptyExpander()
public static <STATE> PathExpander<STATE> emptyPathExpander()
PathExpander
which, if not modified, will expand
all relationships when asked to expand a Node
. Criterias
can be added to narrow the Expansion
.PathExpander
which, if not modified, will expand
all relationship for Path
s.public static Expander expanderForTypes(RelationshipType type1, Direction dir1, RelationshipType type2, Direction dir2)
RelationshipExpander
which is set to expand
relationships with two different types and directions.type1
- a RelationshipType
to expand.dir1
- a Direction
to expand.type2
- another RelationshipType
to expand.dir2
- another Direction
to expand.RelationshipExpander
.public static <STATE> PathExpander<STATE> pathExpanderForTypes(RelationshipType type1, Direction dir1, RelationshipType type2, Direction dir2)
PathExpander
which is set to expand
relationships with two different types and directions.type1
- a RelationshipType
to expand.dir1
- a Direction
to expand.type2
- another RelationshipType
to expand.dir2
- another Direction
to expand.PathExpander
.public static Expander expanderForTypes(RelationshipType type1, Direction dir1, RelationshipType type2, Direction dir2, Object... more)
RelationshipExpander
which is set to expand
relationships with multiple types and directions.type1
- a RelationshipType
to expand.dir1
- a Direction
to expand.type2
- another RelationshipType
to expand.dir2
- another Direction
to expand.more
- additional pairs or type/direction to expand.RelationshipExpander
.public static <STATE> PathExpander<STATE> pathExpanderForTypes(RelationshipType type1, Direction dir1, RelationshipType type2, Direction dir2, Object... more)
PathExpander
which is set to expand
relationships with multiple types and directions.type1
- a RelationshipType
to expand.dir1
- a Direction
to expand.type2
- another RelationshipType
to expand.dir2
- another Direction
to expand.more
- additional pairs or type/direction to expand.PathExpander
.public static Expander expanderForAllTypes()
RelationshipExpander
which expands relationships
of all types and directions.public static <STATE> PathExpander<STATE> pathExpanderForAllTypes()
RelationshipExpander
which expands relationships
of all types and directions.public static Expander expanderForAllTypes(Direction direction)
RelationshipExpander
which expands relationships
of all types in the given direction
.direction
.public static <STATE> PathExpander<STATE> pathExpanderForAllTypes(Direction direction)
PathExpander
which expands relationships
of all types in the given direction
.direction
.public static Expander expander(PathExpander expander)
public static Expander expander(RelationshipExpander expander)
RelationshipExpander
wrapped as an Expander
.expander
- RelationshipExpander
to wrap.RelationshipExpander
wrapped as an Expander
.public static TraversalBranch combineSourcePaths(TraversalBranch source, TraversalBranch target)
TraversalBranch
s with a common
head node
in order to obtain an
TraversalBranch
representing a path from the start node of the
source
TraversalBranch
to the start node of the
target
TraversalBranch
. The resulting
TraversalBranch
will not
) expand further
, and does not provide a
parent
TraversalBranch
.source
- the TraversalBranch
where the resulting path startstarget
- the TraversalBranch
where the resulting path endsTraversalBranch
that represents the path from the
start node of the source
TraversalBranch
to
the start node of the target
TraversalBranch
IllegalArgumentException
- if the head nodes
of the supplied TraversalBranch
s does not
matchpublic static BranchOrderingPolicy preorderDepthFirst()
BranchOrderingPolicy
for a preorder depth first
selector.public static BranchOrderingPolicy postorderDepthFirst()
BranchOrderingPolicy
for a postorder depth first
selector.public static BranchOrderingPolicy preorderBreadthFirst()
BranchOrderingPolicy
for a preorder breadth first
selector.public static BranchOrderingPolicy postorderBreadthFirst()
BranchOrderingPolicy
for a postorder breadth first
selector.public static SideSelectorPolicy alternatingSelectorOrdering()
public static SideSelectorPolicy levelSelectorOrdering()
public static BranchCollisionDetector shortestPathsCollisionDetector(int maxDepth)
public static <T extends Path> String pathToString(T path, Traversal.PathDescriptor<T> builder)
Path
, using
the given builder
.T
- the type of Path
.path
- the Path
to build a string representation of.builder
- the Traversal.PathDescriptor
to get
Node
and Relationship
representations from.Path
.public static String defaultPathToString(Path path)
Path
. It uses
the Traversal.DefaultPathDescriptor
to get representations.public static String simplePathToString(Path path)
Path
. It
doesn't print relationship types or ids, just directions.public static String simplePathToString(Path path, String nodePropertyKey)
Path
. It
doesn't print relationship types or ids, just directions. it uses the
nodePropertyKey
to try to display that property value as in the
node representation instead of the node id. If that property doesn't
exist, the id is used.public static PathDescription path()
Copyright © 2002-2013 The Neo4j Graph Database Project. All Rights Reserved.