Class DepthFirstSearchTraversalStrategy<V,​E>

  • Type Parameters:
    V - the type of the decorated vertex value
    E - the type of the decorated edge value
    All Implemented Interfaces:
    TraversalStrategy<Vertex<V,​E>,​Edge<V,​E>>

    public class DepthFirstSearchTraversalStrategy<V,​E>
    extends Object
    implements TraversalStrategy<Vertex<V,​E>,​Edge<V,​E>>

    Depth-First Search traversal strategy for a given graph PseudoCode:

    
      1 procedure DFS(G, v):
      2     label v as explored
      3     for all edges e in G.incidentEdges(v) do
      4         if edge e is unexplored then
      5             w ← G.adjacentVertex(v, e)
      6             if vertex w is unexplored then
      7                 label e as a discovered edge
      8                 recursively call DFS(G, w)
      9             else
      10               label e as a back edge
      
    Since:
    1.0
    Author:
    Andreas Schuler
    • Constructor Detail

      • DepthFirstSearchTraversalStrategy

        public DepthFirstSearchTraversalStrategy()
    • Method Detail

      • traverse

        public void traverse​(Visitor<Vertex<V,​E>> visitor,
                             Visitor<Edge<V,​E>> edgeVisitor)
        Description copied from interface: TraversalStrategy
        Traverses through the graph
        Specified by:
        traverse in interface TraversalStrategy<V,​E>
        Parameters:
        visitor - visitor which is call when a vertex is visited
        edgeVisitor - visitor which is call when an edge is visited