Interface MutableValueGraph<N,V>
- Type Parameters:
N
- Node parameter typeV
- Value parameter type
- All Superinterfaces:
PredecessorsFunction<N>
,SuccessorsFunction<N>
,ValueGraph<N,
V>
ValueGraph
which adds mutation methods. When mutation is not required,
users should prefer the ValueGraph
interface.- Since:
- 20.0
- Author:
- James Sexton
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Addsnode
if it is not already present.putEdgeValue
(EndpointPair<N> endpoints, V value) Adds an edge connectingendpoints
if one is not already present, and sets a value for that edge tovalue
(overwriting the existing value, if any).putEdgeValue
(N nodeU, N nodeV, V value) Adds an edge connectingnodeU
tonodeV
if one is not already present, and sets a value for that edge tovalue
(overwriting the existing value, if any).removeEdge
(EndpointPair<N> endpoints) Removes the edge connectingendpoints
, if it is present.removeEdge
(N nodeU, N nodeV) Removes the edge connectingnodeU
tonodeV
, if it is present.boolean
removeNode
(N node) Removesnode
if it is present; all edges incident tonode
will also be removed.Methods inherited from interface com.google.common.graph.ValueGraph
adjacentNodes, allowsSelfLoops, asGraph, degree, edges, edgeValue, edgeValue, edgeValueOrDefault, edgeValueOrDefault, equals, hasEdgeConnecting, hasEdgeConnecting, hashCode, incidentEdgeOrder, incidentEdges, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successors
-
Method Details
-
addNode
Addsnode
if it is not already present.Nodes must be unique, just as
Map
keys must be. They must also be non-null.- Returns:
true
if the graph was modified as a result of this call
-
putEdgeValue
Adds an edge connectingnodeU
tonodeV
if one is not already present, and sets a value for that edge tovalue
(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
andnodeV
are not already present in this graph, this method will silentlyadd
nodeU
andnodeV
to the graph.- Returns:
- the value previously associated with the edge connecting
nodeU
tonodeV
, or null if there was no such edge. - Throws:
IllegalArgumentException
- if the introduction of the edge would violateValueGraph.allowsSelfLoops()
-
putEdgeValue
Adds an edge connectingendpoints
if one is not already present, and sets a value for that edge tovalue
(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:
- the value previously associated with the edge connecting
nodeU
tonodeV
, or null if there was no such edge. - Throws:
IllegalArgumentException
- if the introduction of the edge would violateValueGraph.allowsSelfLoops()
IllegalArgumentException
- if the endpoints are unordered and the graph is directed- Since:
- 27.1
-
removeNode
Removesnode
if it is present; all edges incident tonode
will also be removed.- Returns:
true
if the graph was modified as a result of this call
-
removeEdge
Removes the edge connectingnodeU
tonodeV
, if it is present.- Returns:
- the value previously associated with the edge connecting
nodeU
tonodeV
, or null if there was no such edge.
-
removeEdge
Removes the edge connectingendpoints
, if it is present.If this graph is directed,
endpoints
must be ordered.- Returns:
- the value previously associated with the edge connecting
endpoints
, or null if there was no such edge. - Since:
- 27.1
-