salvo.jesus.graph.algorithm
Class DepthFirstDirectedGraphTraversal
java.lang.Object
salvo.jesus.graph.algorithm.GraphTraversal
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
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 |
stack
java.util.Stack stack
dgraph
DirectedGraph dgraph
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.
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 traversalvisitor
- 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