Package com.google.common.graph
Class DirectedGraphConnections<N,V>
java.lang.Object
com.google.common.graph.DirectedGraphConnections<N,V>
- Type Parameters:
N
- Node parameter typeV
- Value parameter type
- All Implemented Interfaces:
GraphConnections<N,
V>
An implementation of
GraphConnections
for directed graphs.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
A value class representing single connection between the origin node and another node.private static final class
A wrapper class to indicate a node is both a predecessor and successor while still providing the successor value. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List
<DirectedGraphConnections.NodeConnection<N>> All node connections in this graph, in edge insertion order.private static final Object
private int
private int
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
DirectedGraphConnections
(Map<N, Object> adjacentNodeValues, List<DirectedGraphConnections.NodeConnection<N>> orderedNodeConnections, int predecessorCount, int successorCount) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPredecessor
(N node, V unused) Addnode
as a predecessor to the origin node.addSuccessor
(N node, V value) Addnode
as a successor to the origin node.incidentEdgeIterator
(N thisNode) Returns an iterator over the incident edges.private static boolean
isPredecessor
(Object value) private static boolean
isSuccessor
(Object value) (package private) static <N,
V> DirectedGraphConnections <N, V> of
(ElementOrder<N> incidentEdgeOrder) (package private) static <N,
V> DirectedGraphConnections <N, V> ofImmutable
(N thisNode, Iterable<EndpointPair<N>> incidentEdges, Function<N, V> successorNodeToValueFn) void
removePredecessor
(N node) Removenode
from the set of predecessors.removeSuccessor
(Object node) Removenode
from the set of successors.Returns the value associated with the edge connecting the origin node tonode
, or null if there is no such edge.
-
Field Details
-
PRED
-
adjacentNodeValues
-
orderedNodeConnections
All node connections in this graph, in edge insertion order.Note: This field and
adjacentNodeValues
cannot be combined into a single LinkedHashMap because one target node may be mapped to both a predecessor and a successor. A LinkedHashMap combines two such edges into a single node-value pair, even though the edges may not have been inserted consecutively. -
predecessorCount
private int predecessorCount -
successorCount
private int successorCount
-
-
Constructor Details
-
DirectedGraphConnections
-
-
Method Details
-
of
-
ofImmutable
static <N,V> DirectedGraphConnections<N,V> ofImmutable(N thisNode, Iterable<EndpointPair<N>> incidentEdges, Function<N, V> successorNodeToValueFn) -
adjacentNodes
- Specified by:
adjacentNodes
in interfaceGraphConnections<N,
V>
-
predecessors
- Specified by:
predecessors
in interfaceGraphConnections<N,
V>
-
successors
- Specified by:
successors
in interfaceGraphConnections<N,
V>
-
incidentEdgeIterator
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
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
Description copied from interface:GraphConnections
Removenode
from the set of predecessors.- Specified by:
removePredecessor
in interfaceGraphConnections<N,
V>
-
removeSuccessor
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
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
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>
-
isPredecessor
-
isSuccessor
-