com.phoenixst.plexus.traversals

Class TopologicalSortTraverser

public class TopologicalSortTraverser extends Object implements Traverser

A Traverser which returns nodes in a topologically sorted order.

Since: 1.0

Version: $Revision: 1.6 $

Author: Ray A. Conner

Constructor Summary
TopologicalSortTraverser(Graph graph, Predicate traverserPredicate)
Creates a new TopologicalSortTraverser, where the traverserPredicate specifies adjacent nodes which should be returned before a given node.
TopologicalSortTraverser(Graph graph, Transformer traverserFactory)
Creates a new TopologicalSortTraverser, where the traverserFactory returns a Traverser over adjacent nodes which should be returned before the given node.
TopologicalSortTraverser(Iterator nodeIter, Transformer traverserFactory)
Creates a new TopologicalSortTraverser, where the traverserFactory returns a Traverser over adjacent nodes which should be returned before the given node.
Method Summary
Graph.EdgegetEdge()
Returns the Edge which was traversed to get to the last node returned by next(), or null if no Edge was traversed.
booleanhasNext()
Objectnext()
voidremove()
voidremoveEdge()

Constructor Detail

TopologicalSortTraverser

public TopologicalSortTraverser(Graph graph, Predicate traverserPredicate)
Creates a new TopologicalSortTraverser, where the traverserPredicate specifies adjacent nodes which should be returned before a given node.

TopologicalSortTraverser

public TopologicalSortTraverser(Graph graph, Transformer traverserFactory)
Creates a new TopologicalSortTraverser, where the traverserFactory returns a Traverser over adjacent nodes which should be returned before the given node.

TopologicalSortTraverser

public TopologicalSortTraverser(Iterator nodeIter, Transformer traverserFactory)
Creates a new TopologicalSortTraverser, where the traverserFactory returns a Traverser over adjacent nodes which should be returned before the given node.

Method Detail

getEdge

public Graph.Edge getEdge()
Returns the Edge which was traversed to get to the last node returned by next(), or null if no Edge was traversed. Note that because the nodes of the underlying Graph are visited in no particular order by the internals of this algorithm, this method may return null even if some other adjacent node succeeds this one.

Description copied from interface: Traverser
{@inheritDoc }

hasNext

public boolean hasNext()

next

public Object next()

remove

public void remove()

removeEdge

public void removeEdge()
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.