Filter:   InfoImg
download DepthFirstDirectedGraphTraversal.java
Language: Java
LOC: 16
Project Info
OpenJGraph
Server: SourceForge
Type: cvs
[Show Code]
[Show Code]
...alvo\jesus\graph\algorithm\
   BreadthFirstTraversal.java
   ...DetectionAlgorithm.java
   ...ectionAlgorithmDFS.java
   ...ctedGraphTraversal.java
   ...irstGraphTraversal.java
   EulerCircleFinder.java
   ...ntractionAlgorithm.java
   GraphTraversal.java
   GraphUnionAlgorithm.java
   ...nningTreeAlgorithm.java
   ...eeKruskalAlgorithm.java
   ShortestPathAlgorithm.java
   ...hDijkstraAlgorithm.java
   TopologicalSorting.java

package salvo.jesus.graph.algorithm;

import salvo.jesus.graph.*;
import java.util.*;

/**
 * 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.
 */

public class DepthFirstDirectedGraphTraversal
    extends DepthFirstGraphTraversal
{
    protected DirectedGraph dgraph;
    
    /**
     * Creates a DepthFirstDirectedGraphTraversal object that will perform
     * a depth first traversal on the specified DirectedGraph
     *
     * @param   graph   DirectedGraph on which the traversal will be performed.
     */
    public DepthFirstDirectedGraphTraversal( DirectedGraph graph ) {
        super( graph );
        dgraph = graph;
    }
    
    /**
     * Override super to only get the outgoing adjacent vertices.
     */
    protected List getAdjacentVertices(Vertex v)
    {
        return dgraph.getOutgoingAdjacentVertices(v);
    }
}