salvo.jesus.graph.algorithm
Class DepthFirstDirectedGraphTraversal

java.lang.Object
  extended by salvo.jesus.graph.algorithm.GraphTraversal
      extended by salvo.jesus.graph.algorithm.DepthFirstDirectedGraphTraversal
All Implemented Interfaces:
java.io.Serializable

public class DepthFirstDirectedGraphTraversal
extends GraphTraversal

A concrete subclass of GraphTraversal that uses depth-first search in traversing a directed graph. Note that the traverse() method will only traverse the connected set to which the Vertex the traversal will start at belongs. Further note that due to the directions of edges, not all vertices may actually be visited by the traversal.

Author:
Jesus M. Salvo Jr.
See Also:
Serialized Form

Field Summary
(package private)  DirectedGraph dgraph
           
(package private)  java.util.Stack stack
           
 
Fields inherited from class salvo.jesus.graph.algorithm.GraphTraversal
graph, OK, TERMINATEDBYVISITOR
 
Constructor Summary
DepthFirstDirectedGraphTraversal(DirectedGraph graph)
          Creates a DepthFirstDirectedGraphTraversal object that will perform a depth first traversal on the specified DirectedGraph
 
Method Summary
 java.util.Vector traverse(Vertex startat)
          Abstract traversal method to be implemented by subclasses.
 int traverse(Vertex startat, java.util.Vector visited, Visitor visitor)
          Abstract traversal method to be implemented by subclasses.
 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

stack

java.util.Stack stack

dgraph

DirectedGraph dgraph
Constructor Detail

DepthFirstDirectedGraphTraversal

public DepthFirstDirectedGraphTraversal(DirectedGraph graph)
Creates a DepthFirstDirectedGraphTraversal object that will perform a depth first traversal on the specified DirectedGraph

Parameters:
graph - DirectedGraph on which the traversal will be performed.
Method Detail

traverse

public int traverse(Vertex startat,
                    java.util.Vector visited,
                    Visitor visitor)
Description copied from class: GraphTraversal
Abstract traversal method to be implemented by subclasses.

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

traverse

public java.util.Vector traverse(Vertex startat)
Description copied from class: GraphTraversal
Abstract traversal method to be implemented by subclasses.

Specified by:
traverse in class GraphTraversal
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 java.util.Vector traverse(Vertex startat,
                                 Visitor visitor)
Description copied from class: GraphTraversal
Abstract traversal method to be implemented by subclasses.

Specified by:
traverse in class GraphTraversal
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