Interface MutableValueGraph<N,V>
-
- Type Parameters:
N- Node parameter typeV- Value parameter type
- All Superinterfaces:
PredecessorsFunction<N>,SuccessorsFunction<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
- Author:
- James Sexton
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanaddNode(N node)Addsnodeif it is not already present.VputEdgeValue(EndpointPair<N> endpoints, V value)Adds an edge connectingendpointsif one is not already present, and sets a value for that edge tovalue(overwriting the existing value, if any).VputEdgeValue(N nodeU, N nodeV, V value)Adds an edge connectingnodeUtonodeVif one is not already present, and sets a value for that edge tovalue(overwriting the existing value, if any).VremoveEdge(EndpointPair<N> endpoints)Removes the edge connectingendpoints, if it is present.VremoveEdge(N nodeU, N nodeV)Removes the edge connectingnodeUtonodeV, if it is present.booleanremoveNode(N node)Removesnodeif it is present; all edges incident tonodewill 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 Detail
-
addNode
@CanIgnoreReturnValue 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
@CanIgnoreReturnValue @CheckForNull V putEdgeValue(N nodeU, N nodeV, V value)
Adds an edge connectingnodeUtonodeVif 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
nodeUandnodeVare not already present in this graph, this method will silentlyaddnodeUandnodeVto the graph.- 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 violateValueGraph.allowsSelfLoops()
-
putEdgeValue
@CanIgnoreReturnValue @CheckForNull V putEdgeValue(EndpointPair<N> endpoints, V value)
Adds an edge connectingendpointsif 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,
endpointsmust 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
addeach missing endpoint to the graph.- 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 violateValueGraph.allowsSelfLoops()java.lang.IllegalArgumentException- if the endpoints are unordered and the graph is directed- Since:
- 27.1
-
removeNode
@CanIgnoreReturnValue boolean removeNode(N 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
@CanIgnoreReturnValue @CheckForNull V removeEdge(N nodeU, N 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.
-
removeEdge
@CanIgnoreReturnValue @CheckForNull V removeEdge(EndpointPair<N> endpoints)
Removes the edge connectingendpoints, if it is present.If this graph is directed,
endpointsmust be ordered.- Returns:
- the value previously associated with the edge connecting
endpoints, or null if there was no such edge. - Since:
- 27.1
-
-