soot.toolkits.graph
Class HashMutableEdgeLabelledDirectedGraph

java.lang.Object
  extended by soot.toolkits.graph.HashMutableEdgeLabelledDirectedGraph
All Implemented Interfaces:
Iterable, DirectedGraph, MutableEdgeLabelledDirectedGraph
Direct Known Subclasses:
HashMutablePDG

public class HashMutableEdgeLabelledDirectedGraph
extends Object
implements MutableEdgeLabelledDirectedGraph


Field Summary
protected  HashMap<soot.toolkits.graph.DGEdge,ArrayList<Object>> edgeToLabels
           
protected  Chain heads
           
protected  HashMap<Object,ArrayList<soot.toolkits.graph.DGEdge>> labelToEdges
           
protected  HashMap<Object,ArrayList> nodeToPreds
           
protected  HashMap<Object,ArrayList> nodeToSuccs
           
protected  Chain tails
           
 
Constructor Summary
HashMutableEdgeLabelledDirectedGraph()
           
 
Method Summary
 void addEdge(Object from, Object to, Object label)
          Adds an edge to the graph between 2 nodes.
 void addNode(Object node)
          Adds a node to the graph.
 void clearAll()
          Removes all nodes and edges.
 Object clone()
           
 boolean containsAnyEdge(Object label)
           
 boolean containsAnyEdge(Object from, Object to)
           
 boolean containsEdge(Object from, Object to, Object label)
           
 boolean containsNode(Object node)
           
 MutableDirectedGraph getEdgesForLabel(Object label)
          Returns a MutableDirectedGraph consisting of all edges with the given label and their nodes.
 List getHeads()
          Returns a list of entry points for this graph.
 List<Object> getLabelsForEdges(Object from, Object to)
          Returns a list of labels for which an edge exists between from and to
 List<Object> getNodes()
           
 List getPredsOf(Object s)
          Returns a list of predecessors for the given node in the graph.
 List getSuccsOf(Object s)
          Returns a list of successors for the given node in the graph.
 List getTails()
          Returns a list of exit points for this graph.
 Iterator iterator()
          Returns an iterator for the nodes in this graph.
 void printGraph()
           
 void removeAllEdges(Object label)
          Removes all edges with the given label in the graph.
 void removeAllEdges(Object from, Object to)
          Removes all edges between 2 nodes in the graph.
 void removeEdge(Object from, Object to, Object label)
          Removes an edge between 2 nodes in the graph.
 void removeNode(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 HashMap<Object,ArrayList> nodeToPreds

nodeToSuccs

protected HashMap<Object,ArrayList> nodeToSuccs

edgeToLabels

protected HashMap<soot.toolkits.graph.DGEdge,ArrayList<Object>> edgeToLabels

labelToEdges

protected HashMap<Object,ArrayList<soot.toolkits.graph.DGEdge>> labelToEdges

heads

protected Chain heads

tails

protected Chain tails
Constructor Detail

HashMutableEdgeLabelledDirectedGraph

public HashMutableEdgeLabelledDirectedGraph()
Method Detail

clearAll

public void clearAll()
Removes all nodes and edges.


clone

public Object clone()
Overrides:
clone in class Object

getHeads

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

Specified by:
getHeads in interface DirectedGraph

getTails

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

Specified by:
getTails in interface DirectedGraph

getPredsOf

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

Specified by:
getPredsOf in interface DirectedGraph

getSuccsOf

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

Specified by:
getSuccsOf in interface DirectedGraph

size

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

Specified by:
size in interface DirectedGraph

iterator

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

Specified by:
iterator in interface Iterable
Specified by:
iterator in interface DirectedGraph

addEdge

public void addEdge(Object from,
                    Object to,
                    Object label)
Description copied from interface: MutableEdgeLabelledDirectedGraph
Adds an edge to the graph between 2 nodes. If the edge is already present no change is made.

Specified by:
addEdge in interface MutableEdgeLabelledDirectedGraph
Parameters:
from - out node for the edge.
to - in node for the edge.
label - label for the edge.

getLabelsForEdges

public List<Object> getLabelsForEdges(Object from,
                                      Object to)
Description copied from interface: MutableEdgeLabelledDirectedGraph
Returns a list of labels for which an edge exists between from and to

Specified by:
getLabelsForEdges in interface MutableEdgeLabelledDirectedGraph
Parameters:
from - out node for the edges to remove.
to - in node for the edges to remove.

getEdgesForLabel

public MutableDirectedGraph getEdgesForLabel(Object label)
Description copied from interface: MutableEdgeLabelledDirectedGraph
Returns a MutableDirectedGraph consisting of all edges with the given label and their nodes. Nodes without edges are not included in the new graph.

Specified by:
getEdgesForLabel in interface MutableEdgeLabelledDirectedGraph
Parameters:
label - label for the edge to remove.

removeEdge

public void removeEdge(Object from,
                       Object to,
                       Object label)
Description copied from interface: MutableEdgeLabelledDirectedGraph
Removes an edge between 2 nodes in the graph. If the edge is not present no change is made.

Specified by:
removeEdge in interface MutableEdgeLabelledDirectedGraph
Parameters:
from - out node for the edges to remove.
to - in node for the edges to remove.
label - label for the edge to remove.

removeAllEdges

public void removeAllEdges(Object from,
                           Object to)
Description copied from interface: MutableEdgeLabelledDirectedGraph
Removes all edges between 2 nodes in the graph. If no edges are present, no change is made.

Specified by:
removeAllEdges in interface MutableEdgeLabelledDirectedGraph
Parameters:
from - out node for the edges to remove.
to - in node for the edges to remove.

removeAllEdges

public void removeAllEdges(Object label)
Description copied from interface: MutableEdgeLabelledDirectedGraph
Removes all edges with the given label in the graph. If no edges are present, no change is made.

Specified by:
removeAllEdges in interface MutableEdgeLabelledDirectedGraph
Parameters:
label - label for the edge to remove.

containsEdge

public boolean containsEdge(Object from,
                            Object to,
                            Object label)
Specified by:
containsEdge in interface MutableEdgeLabelledDirectedGraph
Returns:
true if the graph contains an edge between the 2 nodes with the given label, otherwise return false.

containsAnyEdge

public boolean containsAnyEdge(Object from,
                               Object to)
Specified by:
containsAnyEdge in interface MutableEdgeLabelledDirectedGraph
Parameters:
from - out node for the edges.
to - in node for the edges.
Returns:
true if the graph contains any edges between the 2 nodes, otherwise return false.

containsAnyEdge

public boolean containsAnyEdge(Object label)
Specified by:
containsAnyEdge in interface MutableEdgeLabelledDirectedGraph
Parameters:
label - label for the edges.
Returns:
true if the graph contains any edges with the given label, otherwise return false.

containsNode

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

getNodes

public List<Object> getNodes()
Specified by:
getNodes in interface MutableEdgeLabelledDirectedGraph
Returns:
a list of the nodes that compose the graph. No ordering is implied.

addNode

public void addNode(Object node)
Description copied from interface: MutableEdgeLabelledDirectedGraph
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 MutableEdgeLabelledDirectedGraph
Parameters:
node - a node to add to the graph.
See Also:
DirectedGraph.getHeads(), DirectedGraph.getTails()

removeNode

public void removeNode(Object node)
Description copied from interface: MutableEdgeLabelledDirectedGraph
Removes a node from the graph. If the node is not found in the graph, no change is made.

Specified by:
removeNode in interface MutableEdgeLabelledDirectedGraph
Parameters:
node - the node to be removed.

printGraph

public void printGraph()