shh.util
Class StronglyConn

Object
  extended byStronglyConn

public class StronglyConn
extends Object

If a directed graph implements StronglyConn.Graph, then getSCC(shh.util.StronglyConn.Graph, java.lang.Object) will find its strongly-connected components.

Author:
Mark McConnell

Nested Class Summary
static interface StronglyConn.Graph
          A directed graph, defined purely by local conditions.
 
Constructor Summary
StronglyConn()
           
 
Method Summary
static List getSCC(StronglyConn.Graph g, Object start)
          Strongly-connected components in a directed graph.
static void main(String[] args)
          Runs test(java.lang.String[]).
static void test(String[] args)
          Finds strongly-connected components of a directed 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

StronglyConn

public StronglyConn()
Method Detail

getSCC

public static List getSCC(StronglyConn.Graph g,
                          Object start)
Strongly-connected components in a directed graph. We use an algorithm of Tarjan as presented in Shimon Even, Graph Algorithms, Computer Science Press, 1979, page 65.

Parameters:
start - The vertex at which to start, or null if you don't care.
Returns:
A List of Lists of vertices. Each inner List is a strongly-connected component. The inner Lists appear in the order from sinks to sources. This ordering is not linear, but rather a partial ordering, possibly with incomparable components.

test

public static void test(String[] args)
Finds strongly-connected components of a directed graph whose edges are two-element Strings, with AB meaning the edge from A to B.


main

public static void main(String[] args)
Runs test(java.lang.String[]).