Package com.google.common.graph
Interface MutableGraph<N>
- Type Parameters:
N- Node parameter type
- All Superinterfaces:
Graph<N>
A subinterface of
Graph which adds mutation methods. When mutation is not required, users
should prefer the Graph interface.- Since:
- 20.0
-
Method Summary
Modifier and TypeMethodDescriptionbooleanAddsnodeif it is not already present.booleanAdds an edge connectingnodeUtonodeVif one is not already present.booleanremoveEdge(Object nodeU, Object nodeV) Removes the edge connectingnodeUtonodeV, if it is present.booleanremoveNode(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, equals, hashCode, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successors
-
Method Details
-
addNode
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
Adds an edge connectingnodeUtonodeVif one is not already present. In an undirected graph, the edge will also connectnodeVtonodeU.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:
trueif the graph was modified as a result of this call- Throws:
IllegalArgumentException- if the introduction of the edge would violateGraph.allowsSelfLoops()
-
removeNode
Removesnodeif it is present; all edges incident tonodewill also be removed.- Returns:
trueif the graph was modified as a result of this call
-
removeEdge
Removes the edge connectingnodeUtonodeV, if it is present.- Returns:
trueif the graph was modified as a result of this call
-