public class HashMutableDirectedGraph<N> extends Object implements MutableDirectedGraph<N>
| Modifier and Type | Field and Description |
|---|---|
protected Set<N> |
heads |
protected Map<N,Set<N>> |
nodeToPreds |
protected Map<N,Set<N>> |
nodeToSuccs |
protected Set<N> |
tails |
| Constructor and Description |
|---|
HashMutableDirectedGraph() |
| Modifier and Type | Method and Description |
|---|---|
void |
addEdge(N from,
N to)
Adds an edge to the graph between 2 nodes.
|
void |
addNode(N node)
Adds a node to the graph.
|
void |
clearAll()
Removes all nodes and edges.
|
Object |
clone() |
boolean |
containsEdge(N from,
N to) |
boolean |
containsNode(Object 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 as
getPredsOf(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 as
getSuccsOf(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.
|
void |
printGraph() |
void |
removeEdge(N from,
N to)
Removes an edge between 2 nodes in the graph.
|
void |
removeNode(N node)
Removes a node from the graph.
|
int |
size()
Returns the node count for this graph.
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic void clearAll()
public List<N> getHeads()
DirectedGraphgetHeads in interface DirectedGraph<N>public List<N> getTails()
DirectedGraphgetTails in interface DirectedGraph<N>public List<N> getPredsOf(N s)
DirectedGraphgetPredsOf in interface DirectedGraph<N>public Set<N> getPredsOfAsSet(N s)
getPredsOf(Object) but returns a set. This is faster than calling getPredsOf(Object). Also,
certain operations like Collection.contains(Object) execute faster on the set than on the list. The returned set
is unmodifiable.public List<N> getSuccsOf(N s)
DirectedGraphgetSuccsOf in interface DirectedGraph<N>public Set<N> getSuccsOfAsSet(N s)
getSuccsOf(Object) but returns a set. This is faster than calling getSuccsOf(Object). Also,
certain operations like Collection.contains(Object) execute faster on the set than on the list. The returned set
is unmodifiable.public int size()
DirectedGraphsize in interface DirectedGraph<N>public Iterator<N> iterator()
DirectedGraphpublic void addEdge(N from, N to)
MutableDirectedGraphaddEdge in interface MutableDirectedGraph<N>from - out node for the edge.to - in node for the edge.public void removeEdge(N from, N to)
MutableDirectedGraphremoveEdge in interface MutableDirectedGraph<N>from - out node for the edge to remove.to - in node for the edge to remove.public boolean containsEdge(N from, N to)
containsEdge in interface MutableDirectedGraph<N>public boolean containsNode(Object node)
containsNode in interface MutableDirectedGraph<N>node - node that we want to know if the graph constains.public List<N> getNodes()
getNodes in interface MutableDirectedGraph<N>public void addNode(N node)
MutableDirectedGraphaddNode in interface MutableDirectedGraph<N>node - a node to add to the graph.DirectedGraph.getHeads(),
DirectedGraph.getTails()public void removeNode(N node)
MutableDirectedGraphremoveNode in interface MutableDirectedGraph<N>node - the node to be removed.public void printGraph()
Copyright © 2020 Soot OSS. All rights reserved.