Package com.google.common.graph
Interface MutableGraph<N>
-
- Type Parameters:
N- Node parameter type
- All Superinterfaces:
Graph<N>,PredecessorsFunction<N>,SuccessorsFunction<N>
@Beta public interface MutableGraph<N> extends Graph<N>
A subinterface ofGraphwhich adds mutation methods. When mutation is not required, users should prefer theGraphinterface.- Since:
- 20.0
- Author:
- James Sexton, Joshua O'Madadhain
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanaddNode(N node)Addsnodeif it is not already present.booleanputEdge(N nodeU, N nodeV)Adds an edge connectingnodeUtonodeVif one is not already present.booleanremoveEdge(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.Graph
adjacentNodes, allowsSelfLoops, degree, edges, equals, hasEdgeConnecting, hashCode, incidentEdges, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successors
-
-
-
-
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
-
putEdge
boolean putEdge(N nodeU, N nodeV)
Adds an edge connectingnodeUtonodeVif one is not already present. In an undirected graph, the edge will also connectnodeVtonodeU.If
nodeUandnodeVare not already present in this graph, this method will silentlyaddnodeUandnodeVto the graph.- Returns:
trueif the graph was modified as a result of this call- Throws:
java.lang.IllegalArgumentException- if the introduction of the edge would violateGraph.allowsSelfLoops()
-
removeNode
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
boolean removeEdge(N nodeU, N nodeV)
Removes the edge connectingnodeUtonodeV, if it is present.- Returns:
trueif the graph was modified as a result of this call
-
-