shh.util
Class HopcroftTarjan

Object
  extended byHopcroftTarjan

public class HopcroftTarjan
extends Object

If a graph implements HopcroftTarjan.Graph, then getDFS(shh.util.HopcroftTarjan.Graph, java.lang.Object) will perform a depth-first search on it.

Author:
Mark McConnell

Nested Class Summary
static interface HopcroftTarjan.Graph
          A graph, defined purely by local conditions.
 
Constructor Summary
HopcroftTarjan()
           
 
Method Summary
static Object[] getDFS(HopcroftTarjan.Graph g, Object startingVertex)
          Does a depth-first search (DFS) on g starting at the indicated vertex.
static void main(String[] args)
          Does DFS on a graph whose edges are two-element Strings, with AB meaning the edge from A to B.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HopcroftTarjan

public HopcroftTarjan()
Method Detail

getDFS

public static Object[] getDFS(HopcroftTarjan.Graph g,
                              Object startingVertex)
Does a depth-first search (DFS) on g starting at the indicated vertex. Only the connected component of the starting vertex is discovered. We use the Hopcroft and Tarjan algorithm as presented in Shimon Even, Graph Algorithms, Computer Science Press, 1979, page 56.

Returns:
An array of all the vertices, ordered by discovered-first to discovered-last. (We could modify the code to make it return the mapping vv's parent.)

main

public static void main(String[] args)
Does DFS on a graph whose edges are two-element Strings, with AB meaning the edge from A to B.