Package soot.toolkits.graph
Class HashMutableDirectedGraph<N>
- java.lang.Object
-
- soot.toolkits.graph.HashMutableDirectedGraph<N>
-
- Type Parameters:
N-
- All Implemented Interfaces:
Iterable<N>,DirectedGraph<N>,MutableDirectedGraph<N>
- Direct Known Subclasses:
ExtendedHashMutableDirectedGraph,HashReversibleGraph,MemoryEfficientGraph
public class HashMutableDirectedGraph<N> extends Object implements MutableDirectedGraph<N>
HashMap based implementation of a MutableBlockGraph.
-
-
Constructor Summary
Constructors Constructor Description HashMutableDirectedGraph()HashMutableDirectedGraph(HashMutableDirectedGraph<N> orig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEdge(N from, N to)Adds an edge to the graph between 2 nodes.voidaddNode(N node)Adds a node to the graph.voidclearAll()Removes all nodes and edges.Objectclone()booleancontainsEdge(N from, N to)booleancontainsNode(N node)List<N>getHeads()Returns a list of entry points for this graph.List<N>getNodes()List<N>getPredsOf(N s)Returns a list of predecessors for the given node in the graph.Set<N>getPredsOfAsSet(N s)Same asgetPredsOf(Object)but returns a set.List<N>getSuccsOf(N s)Returns a list of successors for the given node in the graph.Set<N>getSuccsOfAsSet(N s)Same asgetSuccsOf(Object)but returns a set.List<N>getTails()Returns a list of exit points for this graph.Iterator<N>iterator()Returns an iterator for the nodes in this graph.voidprintGraph()voidremoveEdge(N from, N to)Removes an edge between 2 nodes in the graph.voidremoveNode(N node)Removes a node from the graph.intsize()Returns the node count for this graph.-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
HashMutableDirectedGraph
public HashMutableDirectedGraph()
-
HashMutableDirectedGraph
public HashMutableDirectedGraph(HashMutableDirectedGraph<N> orig)
-
-
Method Detail
-
clearAll
public void clearAll()
Removes all nodes and edges.
-
getHeads
public List<N> getHeads()
Description copied from interface:DirectedGraphReturns a list of entry points for this graph.- Specified by:
getHeadsin interfaceDirectedGraph<N>
-
getTails
public List<N> getTails()
Description copied from interface:DirectedGraphReturns a list of exit points for this graph.- Specified by:
getTailsin interfaceDirectedGraph<N>
-
getPredsOf
public List<N> getPredsOf(N s)
Description copied from interface:DirectedGraphReturns a list of predecessors for the given node in the graph.- Specified by:
getPredsOfin interfaceDirectedGraph<N>
-
getPredsOfAsSet
public Set<N> getPredsOfAsSet(N s)
Same asgetPredsOf(Object)but returns a set. This is faster than callinggetPredsOf(Object). Also, certain operations likeCollection.contains(Object)execute faster on the set than on the list. The returned set is unmodifiable.
-
getSuccsOf
public List<N> getSuccsOf(N s)
Description copied from interface:DirectedGraphReturns a list of successors for the given node in the graph.- Specified by:
getSuccsOfin interfaceDirectedGraph<N>
-
getSuccsOfAsSet
public Set<N> getSuccsOfAsSet(N s)
Same asgetSuccsOf(Object)but returns a set. This is faster than callinggetSuccsOf(Object). Also, certain operations likeCollection.contains(Object)execute faster on the set than on the list. The returned set is unmodifiable.
-
size
public int size()
Description copied from interface:DirectedGraphReturns the node count for this graph.- Specified by:
sizein interfaceDirectedGraph<N>
-
iterator
public Iterator<N> iterator()
Description copied from interface:DirectedGraphReturns an iterator for the nodes in this graph. No specific ordering of the nodes is guaranteed.
-
addEdge
public void addEdge(N from, N to)
Description copied from interface:MutableDirectedGraphAdds an edge to the graph between 2 nodes. If the edge is already present no change is made.- Specified by:
addEdgein interfaceMutableDirectedGraph<N>- Parameters:
from- out node for the edge.to- in node for the edge.
-
removeEdge
public void removeEdge(N from, N to)
Description copied from interface:MutableDirectedGraphRemoves an edge between 2 nodes in the graph. If the edge is not present no change is made.- Specified by:
removeEdgein interfaceMutableDirectedGraph<N>- Parameters:
from- out node for the edge to remove.to- in node for the edge to remove.
-
containsEdge
public boolean containsEdge(N from, N to)
- Specified by:
containsEdgein interfaceMutableDirectedGraph<N>- Returns:
- true if the graph contains an edge the 2 nodes false otherwise.
-
containsNode
public boolean containsNode(N node)
- Specified by:
containsNodein interfaceMutableDirectedGraph<N>- 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<N> getNodes()
- Specified by:
getNodesin interfaceMutableDirectedGraph<N>- Returns:
- a list of the nodes that compose the graph. No ordering is implied.
-
addNode
public void addNode(N node)
Description copied from interface:MutableDirectedGraphAdds 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:
addNodein interfaceMutableDirectedGraph<N>- Parameters:
node- a node to add to the graph.- See Also:
DirectedGraph.getHeads(),DirectedGraph.getTails()
-
removeNode
public void removeNode(N node)
Description copied from interface:MutableDirectedGraphRemoves a node from the graph. If the node is not found in the graph, no change is made.- Specified by:
removeNodein interfaceMutableDirectedGraph<N>- Parameters:
node- the node to be removed.
-
printGraph
public void printGraph()
-
-