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 classA value class representing single connection between the origin node and another node.private static final classA 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 Objectprivate intprivate int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateDirectedGraphConnections(Map<N, Object> adjacentNodeValues, List<DirectedGraphConnections.NodeConnection<N>> orderedNodeConnections, int predecessorCount, int successorCount) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPredecessor(N node, V unused) Addnodeas a predecessor to the origin node.addSuccessor(N node, V value) Addnodeas a successor to the origin node.incidentEdgeIterator(N thisNode) Returns an iterator over the incident edges.private static booleanisPredecessor(Object value) private static booleanisSuccessor(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) voidremovePredecessor(N node) Removenodefrom the set of predecessors.removeSuccessor(Object node) Removenodefrom 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
adjacentNodeValuescannot 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:
adjacentNodesin interfaceGraphConnections<N,V>
-
predecessors
- Specified by:
predecessorsin interfaceGraphConnections<N,V>
-
successors
- Specified by:
successorsin interfaceGraphConnections<N,V>
-
incidentEdgeIterator
Description copied from interface:GraphConnectionsReturns an iterator over the incident edges.- Specified by:
incidentEdgeIteratorin interfaceGraphConnections<N,V> - Parameters:
thisNode- The node that this all of the connections in this class are connected to.
-
value
Description copied from interface:GraphConnectionsReturns the value associated with the edge connecting the origin node tonode, or null if there is no such edge.- Specified by:
valuein interfaceGraphConnections<N,V>
-
removePredecessor
Description copied from interface:GraphConnectionsRemovenodefrom the set of predecessors.- Specified by:
removePredecessorin interfaceGraphConnections<N,V>
-
removeSuccessor
Description copied from interface:GraphConnectionsRemovenodefrom the set of successors. Returns the value previously associated with the edge connecting the two nodes.- Specified by:
removeSuccessorin interfaceGraphConnections<N,V>
-
addPredecessor
Description copied from interface:GraphConnectionsAddnodeas a predecessor to the origin node. In the case of an undirected graph, it also becomes a successor. Associatesvaluewith the edge connecting the two nodes.- Specified by:
addPredecessorin interfaceGraphConnections<N,V>
-
addSuccessor
Description copied from interface:GraphConnectionsAddnodeas a successor to the origin node. In the case of an undirected graph, it also becomes a predecessor. Associatesvaluewith the edge connecting the two nodes. Returns the value previously associated with the edge connecting the two nodes.- Specified by:
addSuccessorin interfaceGraphConnections<N,V>
-
isPredecessor
-
isSuccessor
-