public class HashMutableDirectedGraph extends java.lang.Object implements MutableDirectedGraph
| Modifier and Type | Field and Description |
|---|---|
protected Chain |
heads |
protected java.util.HashMap<java.lang.Object,java.util.LinkedHashSet<java.lang.Object>> |
nodeToPreds |
protected java.util.HashMap<java.lang.Object,java.util.LinkedHashSet<java.lang.Object>> |
nodeToSuccs |
protected Chain |
tails |
| Constructor and Description |
|---|
HashMutableDirectedGraph() |
| Modifier and Type | Method and Description |
|---|---|
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<java.lang.Object> |
getNodes() |
java.util.List |
getPredsOf(java.lang.Object s)
Returns a list of predecessors for the given node in the graph.
|
java.util.Set |
getPredsOfAsSet(java.lang.Object s)
Same as
getPredsOf(Object) but returns a set. |
java.util.List |
getSuccsOf(java.lang.Object s)
Returns a list of successors for the given node in the graph.
|
java.util.Set |
getSuccsOfAsSet(java.lang.Object s)
Same as
getSuccsOf(Object) but returns a set. |
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.
|
protected java.util.HashMap<java.lang.Object,java.util.LinkedHashSet<java.lang.Object>> nodeToPreds
protected java.util.HashMap<java.lang.Object,java.util.LinkedHashSet<java.lang.Object>> nodeToSuccs
protected Chain heads
protected Chain tails
public void clearAll()
public java.lang.Object clone()
clone in class java.lang.Objectpublic java.util.List getHeads()
DirectedGraphgetHeads in interface DirectedGraphpublic java.util.List getTails()
DirectedGraphgetTails in interface DirectedGraphpublic java.util.List getPredsOf(java.lang.Object s)
DirectedGraphgetPredsOf in interface DirectedGraphpublic java.util.Set getPredsOfAsSet(java.lang.Object 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 java.util.List getSuccsOf(java.lang.Object s)
DirectedGraphgetSuccsOf in interface DirectedGraphpublic java.util.Set getSuccsOfAsSet(java.lang.Object 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 DirectedGraphpublic java.util.Iterator iterator()
DirectedGraphiterator in interface java.lang.Iterableiterator in interface DirectedGraphpublic void addEdge(java.lang.Object from,
java.lang.Object to)
MutableDirectedGraphaddEdge in interface MutableDirectedGraphfrom - out node for the edge.to - in node for the edge.public void removeEdge(java.lang.Object from,
java.lang.Object to)
MutableDirectedGraphremoveEdge in interface MutableDirectedGraphfrom - out node for the edge to remove.to - in node for the edge to remove.public boolean containsEdge(java.lang.Object from,
java.lang.Object to)
containsEdge in interface MutableDirectedGraphpublic boolean containsNode(java.lang.Object node)
containsNode in interface MutableDirectedGraphnode - node that we want to know if the graph constains.public java.util.List<java.lang.Object> getNodes()
getNodes in interface MutableDirectedGraphpublic void addNode(java.lang.Object node)
MutableDirectedGraphaddNode in interface MutableDirectedGraphnode - a node to add to the graph.DirectedGraph.getHeads(),
DirectedGraph.getTails()public void removeNode(java.lang.Object node)
MutableDirectedGraphremoveNode in interface MutableDirectedGraphnode - the node to be removed.public void printGraph()
Copyright © 2012-2019 RoboVM AB. All Rights Reserved.