soot.toolkits.graph
Class HashMutableDirectedGraph

java.lang.Object
  |
  +--soot.toolkits.graph.HashMutableDirectedGraph
Direct Known Subclasses:
MemoryEfficientGraph

public class HashMutableDirectedGraph
extends java.lang.Object
implements MutableDirectedGraph

HashMap based implementation of a MutableBlockGraph.


Field Summary
protected  Chain heads
           
protected  java.util.HashMap nodeToPreds
           
protected  java.util.HashMap nodeToSuccs
           
protected  Chain tails
           
 
Constructor Summary
HashMutableDirectedGraph()
           
 
Method Summary
 void addEdge(java.lang.Object from, java.lang.Object to)
          Adds an edge to the graph between 2 nodes.
 void addNode(java.lang.Object node)
          Adds a node to the graph.
 void clearAll()
          Removes all nodes and edges.
 java.lang.Object clone()
           
 boolean containsEdge(java.lang.Object from, java.lang.Object to)
           
 boolean containsNode(java.lang.Object node)
           
 java.util.List getHeads()
          Returns a list of entry points for this graph.
 java.util.List getNodes()
           
 java.util.List getPredsOf(java.lang.Object s)
          Returns a list of predecessors for the given node in the graph.
 java.util.List getSuccsOf(java.lang.Object s)
          Returns a list of successors for the given node in the graph.
 java.util.List getTails()
          Returns a list of exit points for this graph.
 java.util.Iterator iterator()
          Returns an iterator for the nodes in this graph.
 void printGraph()
           
 void removeEdge(java.lang.Object from, java.lang.Object to)
          Removes an edge between 2 nodes in the graph.
 void removeNode(java.lang.Object node)
          Removes a node from the graph.
 int size()
          Returns the node count for this graph.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nodeToPreds

protected java.util.HashMap nodeToPreds

nodeToSuccs

protected java.util.HashMap nodeToSuccs

heads

protected Chain heads

tails

protected Chain tails
Constructor Detail

HashMutableDirectedGraph

public HashMutableDirectedGraph()
Method Detail

clearAll

public void clearAll()
Removes all nodes and edges.

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

getHeads

public java.util.List getHeads()
Description copied from interface: DirectedGraph
Returns a list of entry points for this graph.

getTails

public java.util.List getTails()
Description copied from interface: DirectedGraph
Returns a list of exit points for this graph.

getPredsOf

public java.util.List getPredsOf(java.lang.Object s)
Description copied from interface: DirectedGraph
Returns a list of predecessors for the given node in the graph.

getSuccsOf

public java.util.List getSuccsOf(java.lang.Object s)
Description copied from interface: DirectedGraph
Returns a list of successors for the given node in the graph.

size

public int size()
Description copied from interface: DirectedGraph
Returns the node count for this graph.

iterator

public java.util.Iterator iterator()
Description copied from interface: DirectedGraph
Returns an iterator for the nodes in this graph. No specific ordering of the nodes is guaranteed.

addEdge

public void addEdge(java.lang.Object from,
                    java.lang.Object to)
Description copied from interface: MutableDirectedGraph
Adds an edge to the graph between 2 nodes. If the edge is already present no change is made.
Specified by:
addEdge in interface MutableDirectedGraph
Tags copied from interface: MutableDirectedGraph
Parameters:
from - out node for the edge.
to - in node for the edge.

removeEdge

public void removeEdge(java.lang.Object from,
                       java.lang.Object to)
Description copied from interface: MutableDirectedGraph
Removes an edge between 2 nodes in the graph. If the edge is not present no change is made.
Specified by:
removeEdge in interface MutableDirectedGraph
Tags copied from interface: MutableDirectedGraph
Parameters:
from - out node for the edge to remove.
to - in node for the edge to remove.

containsEdge

public boolean containsEdge(java.lang.Object from,
                            java.lang.Object to)
Specified by:
containsEdge in interface MutableDirectedGraph
Tags copied from interface: MutableDirectedGraph
Returns:
true if the graph contains an edge the 2 nodes false otherwise.

containsNode

public boolean containsNode(java.lang.Object node)
Specified by:
containsNode in interface MutableDirectedGraph
Tags copied from interface: MutableDirectedGraph
Parameters:
node - node that we want to know if the graph constains.
Returns:
true if the graph contains the node. false otherwise.

getNodes

public java.util.List getNodes()
Specified by:
getNodes in interface MutableDirectedGraph
Tags copied from interface: MutableDirectedGraph
Returns:
a list of the nodes that compose the graph. No ordering is implied.

addNode

public void addNode(java.lang.Object node)
Description copied from interface: MutableDirectedGraph
Adds a node to the graph. Initially the added node has no successors or predecessors. ; as a consequence it is considered both a head and tail for the graph.
Specified by:
addNode in interface MutableDirectedGraph
Tags copied from interface: MutableDirectedGraph
Parameters:
node - a node to add to the graph.
See Also:
DirectedGraph.getHeads(), DirectedGraph.getTails()

removeNode

public void removeNode(java.lang.Object node)
Description copied from interface: MutableDirectedGraph
Removes a node from the graph. If the node is not found in the graph, no change is made.
Specified by:
removeNode in interface MutableDirectedGraph
Tags copied from interface: MutableDirectedGraph
Parameters:
node - the node to be removed.

printGraph

public void printGraph()