public class HashReversibleGraph<N> extends HashMutableDirectedGraph<N> implements ReversibleGraph<N>
Modifier and Type | Field and Description |
---|---|
protected boolean |
reversed |
heads, nodeToPreds, nodeToSuccs, tails
Constructor and Description |
---|
HashReversibleGraph() |
HashReversibleGraph(DirectedGraph<N> dg) |
Modifier and Type | Method and Description |
---|---|
void |
addEdge(N from,
N to)
Adds an edge to the graph between 2 nodes.
|
boolean |
containsEdge(N from,
N to) |
java.util.List<N> |
getHeads()
Returns a list of entry points for this graph.
|
java.util.List<N> |
getPredsOf(N s)
Returns a list of predecessors for the given node in the graph.
|
java.util.List<N> |
getSuccsOf(N s)
Returns a list of successors for the given node in the graph.
|
java.util.List<N> |
getTails()
Returns a list of exit points for this graph.
|
boolean |
isReversed()
Returns true if the graph is now reversed from its original state
at creation.
|
void |
removeEdge(N from,
N to)
Removes an edge between 2 nodes in the graph.
|
ReversibleGraph<N> |
reverse()
Reverse the edges of the current graph and swap head and tail
nodes.
|
addNode, clearAll, clone, containsNode, getNodes, getPredsOfAsSet, getSuccsOfAsSet, iterator, printGraph, removeNode, size
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addNode, containsNode, getNodes, removeNode
iterator, size
public HashReversibleGraph(DirectedGraph<N> dg)
public HashReversibleGraph()
public boolean isReversed()
ReversibleGraph
isReversed
in interface ReversibleGraph<N>
public ReversibleGraph<N> reverse()
ReversibleGraph
reverse
in interface ReversibleGraph<N>
public void addEdge(N from, N to)
MutableDirectedGraph
addEdge
in interface MutableDirectedGraph<N>
addEdge
in class HashMutableDirectedGraph<N>
from
- out node for the edge.to
- in node for the edge.public void removeEdge(N from, N to)
MutableDirectedGraph
removeEdge
in interface MutableDirectedGraph<N>
removeEdge
in class HashMutableDirectedGraph<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>
containsEdge
in class HashMutableDirectedGraph<N>
public java.util.List<N> getHeads()
DirectedGraph
getHeads
in interface DirectedGraph<N>
getHeads
in class HashMutableDirectedGraph<N>
public java.util.List<N> getTails()
DirectedGraph
getTails
in interface DirectedGraph<N>
getTails
in class HashMutableDirectedGraph<N>
public java.util.List<N> getPredsOf(N s)
DirectedGraph
getPredsOf
in interface DirectedGraph<N>
getPredsOf
in class HashMutableDirectedGraph<N>
public java.util.List<N> getSuccsOf(N s)
DirectedGraph
getSuccsOf
in interface DirectedGraph<N>
getSuccsOf
in class HashMutableDirectedGraph<N>