Package com.google.common.graph
Interface MutableValueGraph<N,V>
- Type Parameters:
N
- Node parameter typeV
- Value parameter type
- All Superinterfaces:
Graph<N>
,ValueGraph<N,
V>
A subinterface of
ValueGraph
which adds mutation methods. When mutation is not required,
users should prefer the ValueGraph
interface.- Since:
- 20.0
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Addsnode
if it is not already present.putEdgeValue
(N nodeU, N nodeV, V value) Adds an edge connectingnodeU
tonodeV
if one is not already present; associate that edge withvalue
.removeEdge
(Object nodeU, Object nodeV) Removes the edge connectingnodeU
tonodeV
, if it is present.boolean
removeNode
(Object node) Removesnode
if it is present; all edges incident tonode
will also be removed.Methods inherited from interface com.google.common.graph.Graph
adjacentNodes, allowsSelfLoops, degree, edges, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successors
Methods inherited from interface com.google.common.graph.ValueGraph
edgeValue, edgeValueOrDefault, equals, hashCode
-
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; associate that edge withvalue
. In an undirected graph, the edge will also connectnodeV
tonodeU
.Values do not have to be unique. However, values must be non-null.
Behavior if
nodeU
andnodeV
are not already present in this graph is implementation-dependent. Suggested behaviors include (a) silentlyadding
nodeU
andnodeV
to the graph (this is the behavior of the default implementations) or (b) throwingIllegalArgumentException
.- 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 violateGraph.allowsSelfLoops()
-
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.
-