jwutil.graphs
Class SCComponent

java.lang.Object
  extended by jwutil.graphs.SCComponent
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public final class SCComponent
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable

SCComponent models a Strongly connected component of a graph. The only way to split a graph into SCComponent s is though buildSCC. That method is quite flexible: all it needs is a root node (or a set of root nodes) and a Navigator : an object implementing the Navigator interface that provides the edges coming into/going out of a given Object. So, it can build strongly connected components even for graphs that are not built up from CFGraphable nodes, a good example being the set of methods where the edges represent the caller-callee relation (in this case, the strongly connected components group together sets of mutually recursive methods).

Version:
$Id: SCComponent.java 2467 2006-06-08 03:03:13Z joewhaley $
Author:
Alexandru SALCIANU
See Also:
Serialized Form

Field Summary
static boolean DETERMINISTIC
           
static Navigator SCC_NAVIGATOR
          Default navigator through a component graph (a dag of strongly connected components).
 
Method Summary
static java.util.Set buildSCC(java.util.Collection roots, Navigator navigator)
          Constructs the strongly connected components of the graph containing all the nodes reachable on paths that originate in nodes from roots.
static java.util.Set buildSCC(Graph graph)
          Convenient version of buildSCC(Object[],Navigator)
static SCComponent buildSCC(java.lang.Object root, Navigator navigator)
          Convenient version for the single root case (see the other buildSCC for details).
 int compareTo(java.lang.Object o)
           
 boolean contains(java.lang.Object node)
          Checks whether node belongs to this\ strongly connected component.
 java.lang.Object[] entries()
          Returns the entry nodes of this strongly connected component.
 boolean equals(java.lang.Object o)
           
 java.lang.Object[] exits()
          Returns the exit nodes of this strongly connected component.
 void fillEntriesAndExits(Navigator nav)
           
 int getId()
          Returns the numeric ID of this SCComponent.
 int hashCode()
           
 boolean isLoop()
          Checks whether this strongly connected component corresponds to a loop, ie it has at least one arc to itself.
 java.util.List listTopSort()
          Returns the list of SCComponent s in topologically-sorted order.
 SCComponent[] next()
           
 SCComponent next(int i)
          Returns the i th successor.
 int nextLength()
          Returns the number of successors.
 SCComponent nextTopSort()
          Returns the next SCComponent according to the decreasing topological order
 java.lang.Object[] nodes()
          Returns the nodes of this strongly connected component; array version - good for iterating over the elements of the SCC.
 java.util.Set nodeSet()
          Returns the nodes of this strongly connected component (set version).
 SCComponent[] prev()
           
 SCComponent prev(int i)
          Returns the i th predecessor.
 int prevLength()
          Returns the number of predecessors.
 SCComponent prevTopSort()
          Returns the previous SCComponent according to the decreasing topological order
 int size()
          Returns the number of nodes in this strongly connected component.
 java.lang.String toString()
          Pretty print debug function.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SCC_NAVIGATOR

public static final Navigator SCC_NAVIGATOR
Default navigator through a component graph (a dag of strongly connected components).


DETERMINISTIC

public static final boolean DETERMINISTIC
See Also:
Constant Field Values
Method Detail

buildSCC

public static final java.util.Set buildSCC(Graph graph)
Convenient version of buildSCC(Object[],Navigator)

Parameters:
graph - directed graph
Returns:
set of graph's strongly connected components

buildSCC

public static final SCComponent buildSCC(java.lang.Object root,
                                         Navigator navigator)
Convenient version for the single root case (see the other buildSCC for details). Returns the single element of the set of top level SCCs.


buildSCC

public static final java.util.Set buildSCC(java.util.Collection roots,
                                           Navigator navigator)
Constructs the strongly connected components of the graph containing all the nodes reachable on paths that originate in nodes from roots. The edges are indicated by navigator. Returns the set of the root SCComponents, the components that are not pointed by any other component. This constraint is actively used in the topological sorting agorithm (see SCCTopSortedGraph).


fillEntriesAndExits

public final void fillEntriesAndExits(Navigator nav)

getId

public int getId()
Returns the numeric ID of this SCComponent. Just for debug purposes ...


isLoop

public final boolean isLoop()
Checks whether this strongly connected component corresponds to a loop, ie it has at least one arc to itself.


compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

nextLength

public final int nextLength()
Returns the number of successors.


next

public final SCComponent next(int i)
Returns the i th successor.


next

public final SCComponent[] next()

prevLength

public final int prevLength()
Returns the number of predecessors.


prev

public final SCComponent prev(int i)
Returns the i th predecessor.


prev

public final SCComponent[] prev()

nodeSet

public final java.util.Set nodeSet()
Returns the nodes of this strongly connected component (set version).


nodes

public final java.lang.Object[] nodes()
Returns the nodes of this strongly connected component; array version - good for iterating over the elements of the SCC.


size

public final int size()
Returns the number of nodes in this strongly connected component.


contains

public final boolean contains(java.lang.Object node)
Checks whether node belongs to this\ strongly connected component.


entries

public final java.lang.Object[] entries()
Returns the entry nodes of this strongly connected component. These are the nodes taht are reachable from outside the component.


exits

public final java.lang.Object[] exits()
Returns the exit nodes of this strongly connected component. These are the nodes that have arcs toward nodes outside the component.


nextTopSort

public final SCComponent nextTopSort()
Returns the next SCComponent according to the decreasing topological order


prevTopSort

public final SCComponent prevTopSort()
Returns the previous SCComponent according to the decreasing topological order


listTopSort

public final java.util.List listTopSort()
Returns the list of SCComponent s in topologically-sorted order.


toString

public final java.lang.String toString()
Pretty print debug function.

Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object


Copyright © 2004-2008 SUIF Compiler Group. All Rights Reserved.