harpoon.Util.Graphs
Class SCComponent

java.lang.Object
  |
  +--harpoon.Util.Graphs.SCComponent
All Implemented Interfaces:
Comparable, Serializable

public final class SCComponent
extends Object
implements Comparable, Serializable

SCComponent models a Strongly connected component \ of a graph. The only way to split a graph into SCComponents is though buildSSC. 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 SCCoomponent.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,v 1.4 2002/04/02 23:48:44 salcianu Exp $
Author:
Alexandru SALCIANU <salcianu@retezat.lcs.mit.edu>
See Also:
Serialized Form

Nested Class Summary
static interface SCComponent.Navigator
          Indentical to harpoon.Util.Graphs.Navigator.
 
Method Summary
static Set buildSCC(Object[] roots, SCComponent.Navigator navigator)
          Constructs the strongly connected components of the graph containing all the nodes reachable on paths that originate in nodes from roots.
static SCComponent buildSCC(Object root, SCComponent.Navigator navigator)
          Convenient version for the single root case (see the other buildSCC for details).
 int compareTo(Object o)
           
 boolean contains(Object node)
          Checks whether node belongs to this \ strongly connected component.
 int getId()
          Returns the numeric ID of this SCComponent.
 boolean isLoop()
          Checks whether this strongly connected component corresponds to a loop, ie it has at least one arc to itself.
 SCComponent next(int i)
          Returns the ith successor.
 int nextLength()
          Returns the number of successors.
 SCComponent nextTopSort()
          Returns the next SCComponent according to the decreasing topological order
 Object[] nodes()
          Returns the nodes of this strongly connected component; array version - good for iterating over the elements of the SCC.
 Set nodeSet()
          Returns the nodes of this strongly connected component (set version).
 SCComponent prev(int i)
          Returns the ith 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.
 String toString()
          Pretty print debug function.
 String toString(MetaCallGraph mcg)
          Pretty print debug function for SCC's of MetaMethods.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

buildSCC

public static final SCComponent buildSCC(Object root,
                                         SCComponent.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 Set buildSCC(Object[] roots,
                                 SCComponent.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).


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(Object o)
Specified by:
compareTo in interface Comparable

nextLength

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


next

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


prevLength

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


prev

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


nodeSet

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


nodes

public final 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(Object node)
Checks whether node belongs to this \ strongly connected 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


toString

public final String toString()
Pretty print debug function.

Overrides:
toString in class Object

toString

public final String toString(MetaCallGraph mcg)
Pretty print debug function for SCC's of MetaMethods.