shh.util
Class HopcroftTarjan
Object
HopcroftTarjan
- 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. |
|
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 |
HopcroftTarjan
public HopcroftTarjan()
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
v →
v'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.