Traversal (Neo4j Apoc 1.1 API)
Keywords: org.neo4j.kernel.Traversal class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
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 `description()` 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 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 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, 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
`<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 PruneEvaluator` | `pruneAfterDepth(int depth)` A `PruneEvaluator` which prunes everything beyond `depth`.
`static Predicate<Path>` | `returnAll()` A traversal return filter which returns all `Path`s it encounters.
`static Predicate<Path>` | `returnAllButStartNode()` A traversal return filter which returns all `Path`s except the position of the start node.
`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`.

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 behaviours to it before traversing.

  Returns:
    a new `TraversalDescription` with default values.

### 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`.

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

### 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`.

### 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`.

### expanderForAllTypes

    public static Expander expanderForAllTypes()

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

### 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

### pruneAfterDepth

    public static PruneEvaluator pruneAfterDepth(int depth)

  A `PruneEvaluator` which prunes everything beyond `depth`.

  Parameters:
    `depth` - the depth to prune beyond (after).
  Returns:
    a `PruneEvaluator` which prunes everything after `depth`.

### returnAll

    public static Predicate<Path> returnAll()

  A traversal return filter which returns all `Path`s it encounters.

  Returns:
    a return filter which returns everything.

### returnAllButStartNode

    public static Predicate<Path> returnAllButStartNode()

  A traversal return filter which returns all `Path`s except the position of the start node.

  Returns:
    a return filter which returns everything except the start node.

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

### 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`.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010 Neo4j. All Rights Reserved.