N
- Node parameter typeV
- Value parameter typefinal class UndirectedGraphConnections<N,V> extends java.lang.Object implements GraphConnections<N,V>
GraphConnections
for undirected graphs.Modifier and Type | Field and Description |
---|---|
private java.util.Map<N,V> |
adjacentNodeValues |
Modifier | Constructor and Description |
---|---|
private |
UndirectedGraphConnections(java.util.Map<N,V> adjacentNodeValues) |
Modifier and Type | Method and Description |
---|---|
void |
addPredecessor(N node,
V value)
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() |
(package private) static <N,V> UndirectedGraphConnections<N,V> |
of() |
(package private) static <N,V> UndirectedGraphConnections<N,V> |
ofImmutable(java.util.Map<N,V> adjacentNodeValues) |
java.util.Set<N> |
predecessors() |
void |
removePredecessor(N node)
Remove
node from the set of predecessors. |
V |
removeSuccessor(N 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. |
static <N,V> UndirectedGraphConnections<N,V> of()
static <N,V> UndirectedGraphConnections<N,V> ofImmutable(java.util.Map<N,V> adjacentNodeValues)
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(N 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 value)
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>