org.neo4j.api.core
Interface Traverser

All Superinterfaces:
Iterable<Node>

public interface Traverser
extends Iterable<Node>

A traversal in the node space. A Traverser is an Iterable that encapsulates a number of traversal parameters (defined at traverser creation) and returns a list of nodes that match those parameters. It is created by invoking Node.traverse(...). Upon creation, the traverser is positioned at the start node, but it doesn't actually start traversing until its iterator().next() method is invoked. Typically it's used in a for-each loop as follows:

 Traverser friends = node.traverse( Order.BREADTH_FIRST,
     StopEvaluator.END_OF_NETWORK, ReturnableEvaluator.ALL_BUT_START_NODE,
     MyRelationshipTypes.KNOWS, Direction.OUTGOING );
 for ( Node friend : friends )
 {
        // ...
 }
 

See Also:
Node.traverse(org.neo4j.api.core.Traverser.Order, org.neo4j.api.core.StopEvaluator, org.neo4j.api.core.ReturnableEvaluator, org.neo4j.api.core.RelationshipType, org.neo4j.api.core.Direction)

Nested Class Summary
static class Traverser.Order
          Defines a traversal order as used by the traversal framework.
 
Method Summary
 TraversalPosition currentPosition()
          Returns the current traversal postion.
 Collection<Node> getAllNodes()
          Returns a collection of all nodes returned by this traverser.
 Iterator<Node> iterator()
          Returns an iterator for this traverser.
 

Method Detail

currentPosition

TraversalPosition currentPosition()
Returns the current traversal postion.

Returns:
The current traversal position

getAllNodes

Collection<Node> getAllNodes()
Returns a collection of all nodes returned by this traverser.

Returns:
A collection of all node returned by this traverser

iterator

Iterator<Node> iterator()
Returns an iterator for this traverser.

Specified by:
iterator in interface Iterable<Node>
Returns:
An iterator for this traverser


Copyright © 2009 Neo4j. All Rights Reserved.