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.kernel
Class Traversal

    java.lang.Object
      org.neo4j.kernel.Traversal

    public class Traversal

extends Object

A factory for objects regarding traversal of the graph. F.ex. it has a method `traversal()` for creating a new `TraversalDescription`, methods for creating new `TraversalBranch` instances and more.

Nested Class Summary
`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 Summary
`Traversal()`

Method Summary
`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)` Returns the default string representation of a `Path`.
`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()` Returns an empty `Expander` which, if not modified, will expand all relationships when asked to expand a `Node`.
`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)` Creates a new `RelationshipExpander` which is set to expand relationships with `type` and `direction`.
`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)`
Creates a new `PathExpander` which is set to expand relationships with `type` and `direction`.
`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> String`

`
`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)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Traversal

    public Traversal()

Method Detail

### description

    public 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. But it isn't a very useful traversal, instead you should add rules and behaviors to it before traversing.

  Returns:
    a new `TraversalDescription` with default values.

### traversal

    public static TraversalDescription traversal()

  More convenient name than `description()` when using static imports. Does the same thing.

  See Also:
    `description()`

### traversal

    public static TraversalDescription traversal(UniquenessFactory uniqueness)

### traversal

    public static TraversalDescription traversal(UniquenessFactory uniqueness,
                                                 Object optionalUniquenessParameter)

### bidirectionalTraversal

    public static BidirectionalTraversalDescription bidirectionalTraversal()

### initialState

    public static <STATE> InitialStateFactory<STATE> initialState(STATE initialState)

  `InitialStateFactory` which always returns the supplied `initialState`.

  Parameters:
    `initialState` - the initial state for a traversal branch.
  Returns:
    an `InitialStateFactory` which always will return the supplied `initialState`.

### expanderForTypes

    public static Expander expanderForTypes(RelationshipType type,
                                            Direction dir)

  Creates a new `RelationshipExpander` which is set to expand relationships with `type` and `direction`.

  Parameters:
    `type` - the `RelationshipType` to expand.
    `dir` - the `Direction` to expand.
  Returns:
    a new `RelationshipExpander`.

### pathExpanderForTypes

    public static <STATE> PathExpander<STATE> pathExpanderForTypes(RelationshipType type,
                                                                   Direction dir)

  Creates a new `PathExpander` which is set to expand relationships with `type` and `direction`.

  Parameters:
    `type` - the `RelationshipType` to expand.
    `dir` - the `Direction` to expand.
  Returns:
    a new `PathExpander`.

### expanderForTypes

    public static Expander expanderForTypes(RelationshipType type)

  Creates a new `RelationshipExpander` which is set to expand relationships with `type` in any direction.

  Parameters:
    `type` - the `RelationshipType` to expand.
  Returns:
    a new `RelationshipExpander`.

### pathExpanderForTypes

    public static <STATE> PathExpander<STATE> pathExpanderForTypes(RelationshipType type)

  Creates a new `PathExpander` which is set to expand relationships with `type` in any direction.

  Parameters:
    `type` - the `RelationshipType` to expand.
  Returns:
    a new `PathExpander`.

### emptyExpander

    public static Expander emptyExpander()

  Returns an empty `Expander` which, if not modified, will expand all relationships when asked to expand a `Node`. Criterias can be added to narrow the `Expansion`.

  Returns:
    an empty `Expander` which, if not modified, will expand all relationship for `Node`s.

### emptyPathExpander

    public static <STATE> PathExpander<STATE> emptyPathExpander()

  Returns an empty `PathExpander` which, if not modified, will expand all relationships when asked to expand a `Node`. Criterias can be added to narrow the `Expansion`.

  Returns:
    an empty `PathExpander` which, if not modified, will expand all relationship for `Path`s.

### expanderForTypes

    public 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.

  Parameters:
    `type1` - a `RelationshipType` to expand.
    `dir1` - a `Direction` to expand.
    `type2` - another `RelationshipType` to expand.
    `dir2` - another `Direction` to expand.
  Returns:
    a new `RelationshipExpander`.

### pathExpanderForTypes

    public 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.

  Parameters:
    `type1` - a `RelationshipType` to expand.
    `dir1` - a `Direction` to expand.
    `type2` - another `RelationshipType` to expand.
    `dir2` - another `Direction` to expand.
  Returns:
    a new `PathExpander`.

### expanderForTypes

    public 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.

  Parameters:
    `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.
  Returns:
    a new `RelationshipExpander`.

### pathExpanderForTypes

    public 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.

  Parameters:
    `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.
  Returns:
    a new `PathExpander`.

### expanderForAllTypes

    public static Expander expanderForAllTypes()

  Returns a `RelationshipExpander` which expands relationships of all types and directions.

  Returns:
    a relationship expander which expands all relationships.

### pathExpanderForAllTypes

    public static <STATE> PathExpander<STATE> pathExpanderForAllTypes()

  Returns a `RelationshipExpander` which expands relationships of all types and directions.

  Returns:
    a relationship expander which expands all relationships.

### expanderForAllTypes

    public static Expander expanderForAllTypes(Direction direction)

  Returns a `RelationshipExpander` which expands relationships of all types in the given `direction`.

  Returns:
    a relationship expander which expands all relationships in the given `direction`.

### pathExpanderForAllTypes

    public static <STATE> PathExpander<STATE> pathExpanderForAllTypes(Direction direction)

  Returns a `PathExpander` which expands relationships of all types in the given `direction`.

  Returns:
    a path expander which expands all relationships in the given `direction`.

### expander

    public static Expander expander(PathExpander expander)

### expander

    public static Expander expander(RelationshipExpander expander)

  Returns a `RelationshipExpander` wrapped as an `Expander`.

  Parameters:
    `expander` - `RelationshipExpander` to wrap.
  Returns:
    a `RelationshipExpander` wrapped as an `Expander`.

### combineSourcePaths

    public 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`. The resulting `TraversalBranch` will not `expand further`, and does not provide a `parent` `TraversalBranch`.

  Parameters:
    `source` - the `TraversalBranch` where the resulting path starts
    `target` - the `TraversalBranch` where the resulting path ends
  Returns:
    an `TraversalBranch` that represents the path from the start node of the `source` `TraversalBranch` to the start node of the `target` `TraversalBranch`
  Throws:
    `IllegalArgumentException` - if the `head nodes` of the supplied `TraversalBranch`s does not match

### preorderDepthFirst

    public static BranchOrderingPolicy preorderDepthFirst()

  Returns a "preorder depth first" ordering policy. A depth first selector always tries to select positions (from the current position) which are deeper than the current position.

  Returns:
    a `BranchOrderingPolicy` for a preorder depth first selector.

### postorderDepthFirst

    public static BranchOrderingPolicy postorderDepthFirst()

  Returns a "postorder depth first" ordering policy. A depth first selector always tries to select positions (from the current position) which are deeper than the current position. A postorder depth first selector selects deeper position before the shallower ones.

  Returns:
    a `BranchOrderingPolicy` for a postorder depth first selector.

### preorderBreadthFirst

    public static BranchOrderingPolicy preorderBreadthFirst()

  Returns a "preorder breadth first" ordering policy. A breadth first selector always selects all positions on the current depth before advancing to the next depth.

  Returns:
    a `BranchOrderingPolicy` for a preorder breadth first selector.

### postorderBreadthFirst

    public static BranchOrderingPolicy postorderBreadthFirst()

  Returns a "postorder breadth first" ordering policy. A breadth first selector always selects all positions on the current depth before advancing to the next depth. A postorder breadth first selector selects the levels in the reversed order, starting with the deepest.

  Returns:
    a `BranchOrderingPolicy` for a postorder breadth first selector.

### alternatingSelectorOrdering

    public static SideSelectorPolicy alternatingSelectorOrdering()

### levelSelectorOrdering

    public static SideSelectorPolicy levelSelectorOrdering()

### shortestPathsCollisionDetector

    public static BranchCollisionDetector shortestPathsCollisionDetector(int maxDepth)

### pathToString

    public static <T extends Path> String pathToString(T path,
                                                       Traversal.PathDescriptor<T> builder)

  Method for building a string representation of a `Path`, using the given `builder`.

  Type Parameters:
    `T` - the type of `Path`.
  Parameters:
    `path` - the `Path` to build a string representation of.
    `builder` - the `Traversal.PathDescriptor` to get `Node` and `Relationship` representations from.
  Returns:
    a string representation of a `Path`.

### defaultPathToString

    public static String defaultPathToString(Path path)

  Returns the default string representation of a `Path`. It uses the `Traversal.DefaultPathDescriptor` to get representations.

  Parameters:
    `path` - the `Path` to build a string representation of.
  Returns:
    the default string representation of a `Path`.

### simplePathToString

    public static String simplePathToString(Path path)

  Returns a quite simple string representation of a `Path`. It doesn't print relationship types or ids, just directions.

  Parameters:
    `path` - the `Path` to build a string representation of.
  Returns:
    a quite simple representation of a `Path`.

### simplePathToString

    public static String simplePathToString(Path path,
                                            String nodePropertyKey)

  Returns a quite simple string representation of a `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.

  Parameters:
    `path` - the `Path` to build a string representation of.
  Returns:
    a quite simple representation of a `Path`.

### path

    public static PathDescription path()

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-2013 The Neo4j Graph Database Project. All Rights Reserved.