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>
@Beta public interface MutableValueGraph<N,V> extends ValueGraph<N,V>
A subinterface ofValueGraphwhich adds mutation methods. When mutation is not required, users should prefer theValueGraphinterface.- Since:
- 20.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanaddNode(N node)Addsnodeif it is not already present.VputEdgeValue(N nodeU, N nodeV, V value)Adds an edge connectingnodeUtonodeVif one is not already present; associate that edge withvalue.VremoveEdge(java.lang.Object nodeU, java.lang.Object nodeV)Removes the edge connectingnodeUtonodeV, if it is present.booleanremoveNode(java.lang.Object node)Removesnodeif it is present; all edges incident tonodewill 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 Detail
-
addNode
boolean addNode(N node)
Addsnodeif it is not already present.Nodes must be unique, just as
Mapkeys must be. They must also be non-null.- Returns:
trueif the graph was modified as a result of this call
-
putEdgeValue
V putEdgeValue(N nodeU, N nodeV, V value)
Adds an edge connectingnodeUtonodeVif one is not already present; associate that edge withvalue. In an undirected graph, the edge will also connectnodeVtonodeU.Values do not have to be unique. However, values must be non-null.
Behavior if
nodeUandnodeVare not already present in this graph is implementation-dependent. Suggested behaviors include (a) silentlyaddingnodeUandnodeVto the graph (this is the behavior of the default implementations) or (b) throwingIllegalArgumentException.- Returns:
- the value previously associated with the edge connecting
nodeUtonodeV, or null if there was no such edge. - Throws:
java.lang.IllegalArgumentException- if the introduction of the edge would violateGraph.allowsSelfLoops()
-
removeNode
boolean removeNode(java.lang.Object node)
Removesnodeif it is present; all edges incident tonodewill also be removed.- Returns:
trueif the graph was modified as a result of this call
-
removeEdge
V removeEdge(java.lang.Object nodeU, java.lang.Object nodeV)
Removes the edge connectingnodeUtonodeV, if it is present.- Returns:
- the value previously associated with the edge connecting
nodeUtonodeV, or null if there was no such edge.
-
-