Top Description Methods
com.google.common.graph

public Interface MutableValueGraph<N, V>

extends ValueGraph<N, V>
Known Direct Implementers
com.google.common.graph.StandardMutableValueGraph
Annotations
@Beta
@ElementTypesAreNonnullByDefault
Type Parameters
<N>
Node parameter type
<V>
Value parameter type
Imports
com.google.common.annotations.Beta, com.google.errorprone.annotations.CanIgnoreReturnValue, javax.annotation.CheckForNull

A subinterface of ValueGraph which adds mutation methods. When mutation is not required, users should prefer the ValueGraph interface.
Author
James Sexton
Since
20.0

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the graph was modified as a result of this call
addNode
(N node)

Adds node if it is not already present.

public V

Returns:

the value previously associated with the edge connecting nodeU to nodeV, or null if there was no such edge.
putEdgeValue
(N nodeU, N nodeV, V value)

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

Returns:

the value previously associated with the edge connecting nodeU to nodeV, or null if there was no such edge.
putEdgeValue
(EndpointPair<N> endpoints, V value)

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

Returns:

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

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

public V

Returns:

the value previously associated with the edge connecting endpoints, or null if there was no such edge.
removeEdge
(EndpointPair<N> endpoints)

Removes the edge connecting endpoints, if it is present.

public boolean

Returns:

true if the graph was modified as a result of this call
removeNode
(N node)

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

Inherited from com.google.common.graph.ValueGraph:
adjacentNodesallowsSelfLoopsasGraphdegreeedgesedgeValueedgeValueedgeValueOrDefaultedgeValueOrDefaultequalshasEdgeConnectinghasEdgeConnectinghashCodeincidentEdgeOrderincidentEdgesinDegreeisDirectednodeOrdernodesoutDegreepredecessorssuccessors

Method Detail

addNodeback to summary
public boolean addNode(N node)

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
@CanIgnoreReturnValue
putEdgeValueback to summary
public V putEdgeValue(N nodeU, N nodeV, V value)

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
@CanIgnoreReturnValue
@CheckForNull
Exceptions
IllegalArgumentException:
if the introduction of the edge would violate allowsSelfLoops()
putEdgeValueback to summary
public V putEdgeValue(EndpointPair<N> endpoints, V value)

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
@CanIgnoreReturnValue
@CheckForNull
Exceptions
IllegalArgumentException:
  • if the introduction of the edge would violate allowsSelfLoops()
  • if the endpoints are unordered and the graph is directed
Since
27.1
removeEdgeback to summary
public V removeEdge(N nodeU, N nodeV)

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
@CanIgnoreReturnValue
@CheckForNull
removeEdgeback to summary
public V removeEdge(EndpointPair<N> endpoints)

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
@CanIgnoreReturnValue
@CheckForNull
Since
27.1
removeNodeback to summary
public boolean removeNode(N node)

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
@CanIgnoreReturnValue