com.phoenixst.plexus.traversals

Class BreadthFirstTraverser

public class BreadthFirstTraverser extends Object implements PruningTraverser

A breadth-first Traverser for a Graph, with no cycle detection. The first node returned is the start node, and no Edge is traversed to reach it. All of the caveats concerning the ordering of the operations hasNext(), next(), and remove() detailed by the Traverser class documentation apply here.

Since: 1.0

Version: $Revision: 1.6 $

Author: Ray A. Conner

Constructor Summary
BreadthFirstTraverser(Object startNode, Graph graph, Predicate traverserPredicate)
Creates a new BreadthFirstTraverser.
BreadthFirstTraverser(Object startNode, OrientedForest forest)
Creates a new BreadthFirstTraverser, which breadth-first traverses the descendants of the specified startNode.
BreadthFirstTraverser(Object startNode, Transformer traverserFactory)
Creates a new BreadthFirstTraverser.
BreadthFirstTraverser(Object startNode, Graph graph, Transformer traverserFactory)
Creates a new BreadthFirstTraverser.
Method Summary
Graph.EdgegetEdge()
booleanhasNext()
Objectnext()
voidprune()
voidremove()
Removes from the underlying Graph the last node returned by BreadthFirstTraverser.
voidremoveEdge()
Removes from the underlying Graph the Edge that would be returned by getEdge().

Constructor Detail

BreadthFirstTraverser

public BreadthFirstTraverser(Object startNode, Graph graph, Predicate traverserPredicate)
Creates a new BreadthFirstTraverser.

BreadthFirstTraverser

public BreadthFirstTraverser(Object startNode, OrientedForest forest)
Creates a new BreadthFirstTraverser, which breadth-first traverses the descendants of the specified startNode. The specified startNode cannot be removed by BreadthFirstTraverser when using this constructor.

BreadthFirstTraverser

public BreadthFirstTraverser(Object startNode, Transformer traverserFactory)
Creates a new BreadthFirstTraverser. The specified startNode cannot be removed by BreadthFirstTraverser when using this constructor.

BreadthFirstTraverser

public BreadthFirstTraverser(Object startNode, Graph graph, Transformer traverserFactory)
Creates a new BreadthFirstTraverser. If the graph argument is null, the specified startNode cannot be removed by BreadthFirstTraverser.

Method Detail

getEdge

public Graph.Edge getEdge()

hasNext

public boolean hasNext()

next

public Object next()

prune

public void prune()

remove

public void remove()
Removes from the underlying Graph the last node returned by BreadthFirstTraverser. This will prevent the exploration of those nodes that would have been reached through the removed node (unless they are reachable by another route). This method can be called only once per call to next(). The behavior of this Traverser is unspecified if the underlying graph structure is modified while the traversal is in progress in any way other than by calling this method or BreadthFirstTraverser.

Throws: IllegalStateException if next() has not yet been called, or remove() or removeEdge has been called after the last call to next().

removeEdge

public void removeEdge()
Removes from the underlying Graph the Edge that would be returned by getEdge(). This will prevent the exploration of those nodes that would have been reached through the removed Edge (unless they are reachable by another route).

Description copied from interface: Traverser
{@inheritDoc }

See the Plexus project home, hosted by SourceForge.
Copyright B) 1994-2006, by Phoenix Software Technologists, Inc. and others. All Rights Reserved. Use is subject to license terms.