N
- Node parameter typeV
- Value parameter typefinal class DirectedGraphConnections<N,V> extends java.lang.Object implements GraphConnections<N,V>
GraphConnections
for directed graphs.Modifier and Type | Class and Description |
---|---|
private static class |
DirectedGraphConnections.PredAndSucc
A wrapper class to indicate a node is both a predecessor and successor while still providing
the successor value.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Map<N,java.lang.Object> |
adjacentNodeValues |
private static java.lang.Object |
PRED |
private int |
predecessorCount |
private int |
successorCount |
Modifier | Constructor and Description |
---|---|
private |
DirectedGraphConnections(java.util.Map<N,java.lang.Object> adjacentNodeValues,
int predecessorCount,
int successorCount) |
Modifier and Type | Method and Description |
---|---|
void |
addPredecessor(N node,
V unused)
Add
node as a predecessor to the origin node. |
V |
addSuccessor(N node,
V value)
Add
node as a successor to the origin node. |
java.util.Set<N> |
adjacentNodes() |
private static boolean |
isPredecessor(java.lang.Object value) |
private static boolean |
isSuccessor(java.lang.Object value) |
(package private) static <N,V> DirectedGraphConnections<N,V> |
of() |
(package private) static <N,V> DirectedGraphConnections<N,V> |
ofImmutable(java.util.Set<N> predecessors,
java.util.Map<N,V> successorValues) |
java.util.Set<N> |
predecessors() |
void |
removePredecessor(N node)
Remove
node from the set of predecessors. |
V |
removeSuccessor(java.lang.Object node)
Remove
node from the set of successors. |
java.util.Set<N> |
successors() |
V |
value(N node)
Returns the value associated with the edge connecting the origin node to
node , or null
if there is no such edge. |
private static final java.lang.Object PRED
private final java.util.Map<N,java.lang.Object> adjacentNodeValues
private int predecessorCount
private int successorCount
private DirectedGraphConnections(java.util.Map<N,java.lang.Object> adjacentNodeValues, int predecessorCount, int successorCount)
static <N,V> DirectedGraphConnections<N,V> of()
static <N,V> DirectedGraphConnections<N,V> ofImmutable(java.util.Set<N> predecessors, java.util.Map<N,V> successorValues)
public java.util.Set<N> adjacentNodes()
adjacentNodes
in interface GraphConnections<N,V>
public java.util.Set<N> predecessors()
predecessors
in interface GraphConnections<N,V>
public java.util.Set<N> successors()
successors
in interface GraphConnections<N,V>
public V value(N node)
GraphConnections
node
, or null
if there is no such edge.value
in interface GraphConnections<N,V>
public void removePredecessor(N node)
GraphConnections
node
from the set of predecessors.removePredecessor
in interface GraphConnections<N,V>
public V removeSuccessor(java.lang.Object node)
GraphConnections
node
from the set of successors. Returns the value previously associated with
the edge connecting the two nodes.removeSuccessor
in interface GraphConnections<N,V>
public void addPredecessor(N node, V unused)
GraphConnections
node
as a predecessor to the origin node. In the case of an undirected graph, it
also becomes a successor. Associates value
with the edge connecting the two nodes.addPredecessor
in interface GraphConnections<N,V>
public V addSuccessor(N node, V value)
GraphConnections
node
as a successor to the origin node. In the case of an undirected graph, it also
becomes a predecessor. Associates value
with the edge connecting the two nodes. Returns
the value previously associated with the edge connecting the two nodes.addSuccessor
in interface GraphConnections<N,V>
private static boolean isPredecessor(java.lang.Object value)
private static boolean isSuccessor(java.lang.Object value)