Package soot.toolkits.graph
Class HashMutableEdgeLabelledDirectedGraph<N,L>
- java.lang.Object
-
- soot.toolkits.graph.HashMutableEdgeLabelledDirectedGraph<N,L>
-
- Type Parameters:
N-L-
- All Implemented Interfaces:
Iterable<N>,DirectedGraph<N>,EdgeLabelledDirectedGraph<N,L>,MutableEdgeLabelledDirectedGraph<N,L>
- Direct Known Subclasses:
HashMutablePDG
public class HashMutableEdgeLabelledDirectedGraph<N,L> extends Object implements MutableEdgeLabelledDirectedGraph<N,L>
HashMap based implementation of a MutableEdgeLabelledDirectedGraph.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classHashMutableEdgeLabelledDirectedGraph.DGEdge<N>
-
Field Summary
Fields Modifier and Type Field Description protected Map<HashMutableEdgeLabelledDirectedGraph.DGEdge<N>,List<L>>edgeToLabelsprotected Set<N>headsprotected Map<L,List<HashMutableEdgeLabelledDirectedGraph.DGEdge<N>>>labelToEdgesprotected Map<N,List<N>>nodeToPredsprotected Map<N,List<N>>nodeToSuccsprotected Set<N>tails
-
Constructor Summary
Constructors Constructor Description HashMutableEdgeLabelledDirectedGraph()HashMutableEdgeLabelledDirectedGraph(HashMutableEdgeLabelledDirectedGraph<N,L> orig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEdge(N from, N to, L label)Adds an edge to the graph between 2 nodes.voidaddNode(N node)Adds a node to the graph.voidclearAll()Removes all nodes and edges.HashMutableEdgeLabelledDirectedGraph<N,L>clone()booleancontainsAnyEdge(L label)booleancontainsAnyEdge(N from, N to)booleancontainsEdge(N from, N to, L label)booleancontainsNode(N node)MutableDirectedGraph<N>getEdgesForLabel(L label)Returns a DirectedGraph consisting of all edges with the given label and their nodes.List<N>getHeads()Returns a list of entry points for this graph.List<L>getLabelsForEdges(N from, N to)Returns a list of labels for which an edge exists between from and toList<N>getPredsOf(N s)Returns a list of predecessors for the given node in the graph.List<N>getSuccsOf(N s)Returns a list of successors for the given node in the graph.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()voidremoveAllEdges(L label)Removes all edges with the given label in the graph.voidremoveAllEdges(N from, N to)Removes all edges between 2 nodes in the graph.voidremoveEdge(N from, N to, L label)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
-
-
-
-
Field Detail
-
edgeToLabels
protected final Map<HashMutableEdgeLabelledDirectedGraph.DGEdge<N>,List<L>> edgeToLabels
-
labelToEdges
protected final Map<L,List<HashMutableEdgeLabelledDirectedGraph.DGEdge<N>>> labelToEdges
-
-
Constructor Detail
-
HashMutableEdgeLabelledDirectedGraph
public HashMutableEdgeLabelledDirectedGraph()
-
HashMutableEdgeLabelledDirectedGraph
public HashMutableEdgeLabelledDirectedGraph(HashMutableEdgeLabelledDirectedGraph<N,L> orig)
-
-
Method Detail
-
clone
public HashMutableEdgeLabelledDirectedGraph<N,L> clone()
-
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>
-
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>
-
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, L label)
Description copied from interface:MutableEdgeLabelledDirectedGraphAdds an edge to the graph between 2 nodes. If the edge is already present no change is made.- Specified by:
addEdgein interfaceMutableEdgeLabelledDirectedGraph<N,L>- Parameters:
from- out node for the edge.to- in node for the edge.label- label for the edge.
-
getLabelsForEdges
public List<L> getLabelsForEdges(N from, N to)
Description copied from interface:EdgeLabelledDirectedGraphReturns a list of labels for which an edge exists between from and to- Specified by:
getLabelsForEdgesin interfaceEdgeLabelledDirectedGraph<N,L>- Parameters:
from- out node of the edges to get labels forto- in node of the edges to get labels for- Returns:
-
getEdgesForLabel
public MutableDirectedGraph<N> getEdgesForLabel(L label)
Description copied from interface:EdgeLabelledDirectedGraphReturns a DirectedGraph consisting of all edges with the given label and their nodes. Nodes without edges are not included in the new graph.- Specified by:
getEdgesForLabelin interfaceEdgeLabelledDirectedGraph<N,L>- Parameters:
label- edge label to use as a filter in building the subgraph- Returns:
-
removeEdge
public void removeEdge(N from, N to, L label)
Description copied from interface:MutableEdgeLabelledDirectedGraphRemoves an edge between 2 nodes in the graph. If the edge is not present no change is made.- Specified by:
removeEdgein interfaceMutableEdgeLabelledDirectedGraph<N,L>- 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(N from, N to)
Description copied from interface:MutableEdgeLabelledDirectedGraphRemoves all edges between 2 nodes in the graph. If no edges are present, no change is made.- Specified by:
removeAllEdgesin interfaceMutableEdgeLabelledDirectedGraph<N,L>- Parameters:
from- out node for the edges to remove.to- in node for the edges to remove.
-
removeAllEdges
public void removeAllEdges(L label)
Description copied from interface:MutableEdgeLabelledDirectedGraphRemoves all edges with the given label in the graph. If no edges are present, no change is made.- Specified by:
removeAllEdgesin interfaceMutableEdgeLabelledDirectedGraph<N,L>- Parameters:
label- label for the edge to remove.
-
containsEdge
public boolean containsEdge(N from, N to, L label)
- Specified by:
containsEdgein interfaceEdgeLabelledDirectedGraph<N,L>- Returns:
- true if the graph contains an edge between the 2 nodes with the given label, false otherwise
-
containsAnyEdge
public boolean containsAnyEdge(N from, N to)
- Specified by:
containsAnyEdgein interfaceEdgeLabelledDirectedGraph<N,L>- Parameters:
from- out node for the edgesto- in node for the edges- Returns:
- true if the graph contains any edges between the 2 nodes, false, otherwise
-
containsAnyEdge
public boolean containsAnyEdge(L label)
- Specified by:
containsAnyEdgein interfaceEdgeLabelledDirectedGraph<N,L>- Parameters:
label- label for the edges- Returns:
- true if the graph contains any edges with the given label, false otherwise
-
containsNode
public boolean containsNode(N node)
- Specified by:
containsNodein interfaceEdgeLabelledDirectedGraph<N,L>- Parameters:
node- node that we want to know if the graph contains- Returns:
- true if the graph contains the node, false otherwise
-
addNode
public void addNode(N node)
Description copied from interface:MutableEdgeLabelledDirectedGraphAdds 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 interfaceMutableEdgeLabelledDirectedGraph<N,L>- 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:MutableEdgeLabelledDirectedGraphRemoves a node from the graph. If the node is not found in the graph, no change is made.- Specified by:
removeNodein interfaceMutableEdgeLabelledDirectedGraph<N,L>- Parameters:
node- the node to be removed.
-
printGraph
public void printGraph()
-
-