Package com.google.common.graph
Class UndirectedGraphConnections<N,V>
- java.lang.Object
-
- com.google.common.graph.UndirectedGraphConnections<N,V>
-
- Type Parameters:
N
- Node parameter typeV
- Value parameter type
- All Implemented Interfaces:
GraphConnections<N,V>
final class UndirectedGraphConnections<N,V> extends java.lang.Object implements GraphConnections<N,V>
An implementation ofGraphConnections
for undirected graphs.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<N,V>
adjacentNodeValues
-
Constructor Summary
Constructors Modifier Constructor Description private
UndirectedGraphConnections(java.util.Map<N,V> adjacentNodeValues)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPredecessor(N node, V value)
Addnode
as a predecessor to the origin node.V
addSuccessor(N node, V value)
Addnode
as a successor to the origin node.java.util.Set<N>
adjacentNodes()
java.util.Iterator<EndpointPair<N>>
incidentEdgeIterator(N thisNode)
Returns an iterator over the incident edges.(package private) static <N,V>
UndirectedGraphConnections<N,V>of(ElementOrder<N> incidentEdgeOrder)
(package private) static <N,V>
UndirectedGraphConnections<N,V>ofImmutable(java.util.Map<N,V> adjacentNodeValues)
java.util.Set<N>
predecessors()
void
removePredecessor(N node)
Removenode
from the set of predecessors.V
removeSuccessor(N node)
Removenode
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 tonode
, or null if there is no such edge.
-
-
-
Method Detail
-
of
static <N,V> UndirectedGraphConnections<N,V> of(ElementOrder<N> incidentEdgeOrder)
-
ofImmutable
static <N,V> UndirectedGraphConnections<N,V> ofImmutable(java.util.Map<N,V> adjacentNodeValues)
-
adjacentNodes
public java.util.Set<N> adjacentNodes()
- Specified by:
adjacentNodes
in interfaceGraphConnections<N,V>
-
predecessors
public java.util.Set<N> predecessors()
- Specified by:
predecessors
in interfaceGraphConnections<N,V>
-
successors
public java.util.Set<N> successors()
- Specified by:
successors
in interfaceGraphConnections<N,V>
-
incidentEdgeIterator
public java.util.Iterator<EndpointPair<N>> incidentEdgeIterator(N thisNode)
Description copied from interface:GraphConnections
Returns an iterator over the incident edges.- Specified by:
incidentEdgeIterator
in interfaceGraphConnections<N,V>
- Parameters:
thisNode
- The node that this all of the connections in this class are connected to.
-
value
@CheckForNull public V value(N node)
Description copied from interface:GraphConnections
Returns the value associated with the edge connecting the origin node tonode
, or null if there is no such edge.- Specified by:
value
in interfaceGraphConnections<N,V>
-
removePredecessor
public void removePredecessor(N node)
Description copied from interface:GraphConnections
Removenode
from the set of predecessors.- Specified by:
removePredecessor
in interfaceGraphConnections<N,V>
-
removeSuccessor
@CheckForNull public V removeSuccessor(N node)
Description copied from interface:GraphConnections
Removenode
from the set of successors. Returns the value previously associated with the edge connecting the two nodes.- Specified by:
removeSuccessor
in interfaceGraphConnections<N,V>
-
addPredecessor
public void addPredecessor(N node, V value)
Description copied from interface:GraphConnections
Addnode
as a predecessor to the origin node. In the case of an undirected graph, it also becomes a successor. Associatesvalue
with the edge connecting the two nodes.- Specified by:
addPredecessor
in interfaceGraphConnections<N,V>
-
addSuccessor
@CheckForNull public V addSuccessor(N node, V value)
Description copied from interface:GraphConnections
Addnode
as a successor to the origin node. In the case of an undirected graph, it also becomes a predecessor. Associatesvalue
with the edge connecting the two nodes. Returns the value previously associated with the edge connecting the two nodes.- Specified by:
addSuccessor
in interfaceGraphConnections<N,V>
-
-