salvo.jesus.graph.algorithm
Class GraphTraversal

java.lang.Object
  extended by salvo.jesus.graph.algorithm.GraphTraversal
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BreadthFirstTraversal, DepthFirstDirectedGraphTraversal, DepthFirstGraphTraversal, TopologicalSorting

public abstract class GraphTraversal
extends java.lang.Object
implements java.io.Serializable

Abstract class for an algorithm implementing graph traversal. Classes implementing the Graph interface uses the Strategy pattern to allow different implementations of the graph traversal algorithm to be used. Concrete implementations of this class must never modify the Graph itself.

See Also:
Serialized Form

Field Summary
(package private)  Graph graph
          The Graph on which graph traversal will be performed.
static int OK
           
static int TERMINATEDBYVISITOR
           
 
Constructor Summary
GraphTraversal(Graph graph)
           
 
Method Summary
abstract  java.util.Vector traverse(Vertex startat)
          Abstract traversal method to be implemented by subclasses.
abstract  int traverse(Vertex startat, java.util.Vector visited, Visitor visitor)
          Abstract traversal method to be implemented by subclasses.
abstract  java.util.Vector traverse(Vertex startat, Visitor visitor)
          Abstract traversal method to be implemented by subclasses.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TERMINATEDBYVISITOR

public static final int TERMINATEDBYVISITOR
See Also:
Constant Field Values

OK

public static final int OK
See Also:
Constant Field Values

graph

Graph graph
The Graph on which graph traversal will be performed.

Constructor Detail

GraphTraversal

public GraphTraversal(Graph graph)
Method Detail

traverse

public abstract int traverse(Vertex startat,
                             java.util.Vector visited,
                             Visitor visitor)
Abstract traversal method to be implemented by subclasses.

Parameters:
startat - The vertex from which traversal will start.
visitor - Visitor object controlling if and when traversal will stop, apart from having visited all the vertices.
visited - A Vector of vertices that has been visited in sequence by the traversal

traverse

public abstract java.util.Vector traverse(Vertex startat)
Abstract traversal method to be implemented by subclasses.

Parameters:
startat - The vertex from which traversal will start.
Returns:
A Vector of vertices that has been visited in sequence by the traversal

traverse

public abstract java.util.Vector traverse(Vertex startat,
                                          Visitor visitor)
Abstract traversal method to be implemented by subclasses.

Parameters:
startat - The vertex from which traversal will start.
visitor - Visitor object controlling if and when traversal will stop, apart from having visited all the vertices.
Returns:
A Vector of vertices that has been visited in sequence by the traversal