Top Description Fields Constructors Methods
com.google.common.graph

pack-priv final Class StandardMutableValueGraph<N, V>

extends StandardValueGraph<N, V>
implements MutableValueGraph<N, V>
Class Inheritance
All Implemented Interfaces
com.google.common.graph.MutableValueGraph, com.google.common.graph.ValueGraph, com.google.common.graph.BaseGraph, com.google.common.graph.PredecessorsFunction, com.google.common.graph.SuccessorsFunction
Annotations
@ElementTypesAreNonnullByDefault
Type Parameters
<N>
Node parameter type
<V>
Value parameter type
Static Imports
com.google.common.base.Preconditions.checkArgument, .Preconditions.checkNotNull, .Preconditions.checkState, com.google.common.graph.GraphConstants.SELF_LOOPS_NOT_ALLOWED, .Graphs.checkNonNegative, .Graphs.checkPositive, java.util.Objects.requireNonNull

Standard implementation of MutableValueGraph that supports both directed and undirected graphs. Instances of this class should be constructed with ValueGraphBuilder.

Time complexities for mutation methods are all O(1) except for removeNode(N node), which is in O(d_node) where d_node is the degree of node.

Authors
James Sexton, Joshua O'Madadhain, Omar Darwish

Field Summary

Modifier and TypeField and Description
private final ElementOrder<N>
Inherited from com.google.common.graph.StandardValueGraph:
edgeCountnodeConnections

Constructor Summary

AccessConstructor and Description
pack-priv
StandardMutableValueGraph(AbstractGraphBuilder<? super N> builder)

Constructs a mutable graph with the properties specified in builder.

Method Summary

Modifier and TypeMethod and Description
public boolean
addNode(N node)

Implements com.google.common.graph.MutableValueGraph.addNode.

Adds node if it is not already present.
private GraphConnections<N, V>
addNodeInternal(N node)

Adds node to the graph and returns the associated GraphConnections.

public ElementOrder<N>
private GraphConnections<N, V>
public V
putEdgeValue(N nodeU, N nodeV, V value)

Implements com.google.common.graph.MutableValueGraph.putEdgeValue.

Adds an edge connecting nodeU to nodeV if one is not already present, and sets a value for that edge to value (overwriting the existing value, if any).
public V
putEdgeValue(EndpointPair<N> endpoints, V value)

Implements com.google.common.graph.MutableValueGraph.putEdgeValue.

Adds an edge connecting endpoints if one is not already present, and sets a value for that edge to value (overwriting the existing value, if any).
public V
removeEdge(N nodeU, N nodeV)

Implements com.google.common.graph.MutableValueGraph.removeEdge.

Removes the edge connecting nodeU to nodeV, if it is present.
public V
removeEdge(EndpointPair<N> endpoints)

Implements com.google.common.graph.MutableValueGraph.removeEdge.

Removes the edge connecting endpoints, if it is present.
public boolean
removeNode(N node)

Implements com.google.common.graph.MutableValueGraph.removeNode.

Removes node if it is present; all edges incident to node will also be removed.
Inherited from com.google.common.graph.StandardValueGraph:
adjacentNodesallowsSelfLoopscontainsNodeedgeCountedgeValueOrDefaultedgeValueOrDefaulthasEdgeConnectinghasEdgeConnectingincidentEdgesisDirectednodeOrdernodespredecessorssuccessors

Field Detail

incidentEdgeOrderback to summary
private final ElementOrder<N> incidentEdgeOrder

Constructor Detail

StandardMutableValueGraphback to summary
pack-priv StandardMutableValueGraph(AbstractGraphBuilder<? super N> builder)

Constructs a mutable graph with the properties specified in builder.

Method Detail

addNodeback to summary
public boolean addNode(N node)

Implements com.google.common.graph.MutableValueGraph.addNode.

Doc from com.google.common.graph.MutableValueGraph.addNode.

Adds node if it is not already present.

Nodes must be unique, just as Map keys must be. They must also be non-null.

Returns:boolean

true if the graph was modified as a result of this call

Annotations
@Override
@CanIgnoreReturnValue
addNodeInternalback to summary
private GraphConnections<N, V> addNodeInternal(N node)

Adds node to the graph and returns the associated GraphConnections.

Annotations
@CanIgnoreReturnValue
Exceptions
IllegalStateException:
if node is already present
incidentEdgeOrderback to summary
public ElementOrder<N> incidentEdgeOrder()

Overrides com.google.common.graph.AbstractBaseGraph.incidentEdgeOrder.

Implements com.google.common.graph.ValueGraph.incidentEdgeOrder, com.google.common.graph.BaseGraph.incidentEdgeOrder.

Doc from com.google.common.graph.ValueGraph.incidentEdgeOrder.

Returns an ElementOrder that specifies the order of iteration for the elements of edges(), adjacentNodes(Object), predecessors(Object), successors(Object) and incidentEdges(Object).

Annotations
@Override
newConnectionsback to summary
private GraphConnections<N, V> newConnections()
putEdgeValueback to summary
public V putEdgeValue(N nodeU, N nodeV, V value)

Implements com.google.common.graph.MutableValueGraph.putEdgeValue.

Doc from com.google.common.graph.MutableValueGraph.putEdgeValue.

Adds an edge connecting nodeU to nodeV if one is not already present, and sets a value for that edge to value (overwriting the existing value, if any).

If the graph is directed, the resultant edge will be directed; otherwise, it will be undirected.

Values do not have to be unique. However, values must be non-null.

If nodeU and nodeV are not already present in this graph, this method will silently add nodeU and nodeV to the graph.

Returns:V

the value previously associated with the edge connecting nodeU to nodeV, or null if there was no such edge.

Annotations
@Override
@CanIgnoreReturnValue
@CheckForNull
putEdgeValueback to summary
public V putEdgeValue(EndpointPair<N> endpoints, V value)

Implements com.google.common.graph.MutableValueGraph.putEdgeValue.

Doc from com.google.common.graph.MutableValueGraph.putEdgeValue.

Adds an edge connecting endpoints if one is not already present, and sets a value for that edge to value (overwriting the existing value, if any).

If the graph is directed, the resultant edge will be directed; otherwise, it will be undirected.

If this graph is directed, endpoints must be ordered.

Values do not have to be unique. However, values must be non-null.

If either or both endpoints are not already present in this graph, this method will silently add each missing endpoint to the graph.

Returns:V

the value previously associated with the edge connecting nodeU to nodeV, or null if there was no such edge.

Annotations
@Override
@CanIgnoreReturnValue
@CheckForNull
removeEdgeback to summary
public V removeEdge(N nodeU, N nodeV)

Implements com.google.common.graph.MutableValueGraph.removeEdge.

Doc from com.google.common.graph.MutableValueGraph.removeEdge.

Removes the edge connecting nodeU to nodeV, if it is present.

Returns:V

the value previously associated with the edge connecting nodeU to nodeV, or null if there was no such edge.

Annotations
@Override
@CanIgnoreReturnValue
@CheckForNull
removeEdgeback to summary
public V removeEdge(EndpointPair<N> endpoints)

Implements com.google.common.graph.MutableValueGraph.removeEdge.

Doc from com.google.common.graph.MutableValueGraph.removeEdge.

Removes the edge connecting endpoints, if it is present.

If this graph is directed, endpoints must be ordered.

Returns:V

the value previously associated with the edge connecting endpoints, or null if there was no such edge.

Annotations
@Override
@CanIgnoreReturnValue
@CheckForNull
removeNodeback to summary
public boolean removeNode(N node)

Implements com.google.common.graph.MutableValueGraph.removeNode.

Doc from com.google.common.graph.MutableValueGraph.removeNode.

Removes node if it is present; all edges incident to node will also be removed.

Returns:boolean

true if the graph was modified as a result of this call

Annotations
@Override
@CanIgnoreReturnValue