Package com.google.common.graph
Interface MutableGraph<N>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
addNode(N node)
Addsnode
if it is not already present.boolean
putEdge(N nodeU, N nodeV)
Adds an edge connectingnodeU
tonodeV
if one is not already present.boolean
removeEdge(java.lang.Object nodeU, java.lang.Object nodeV)
Removes the edge connectingnodeU
tonodeV
, if it is present.boolean
removeNode(java.lang.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, equals, hashCode, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successors
-
-
-
-
Method Detail
-
addNode
boolean addNode(N node)
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
-
putEdge
boolean putEdge(N nodeU, N nodeV)
Adds an edge connectingnodeU
tonodeV
if one is not already present. In an undirected graph, the edge will also connectnodeV
tonodeU
.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:
true
if 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(java.lang.Object node)
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
boolean removeEdge(java.lang.Object nodeU, java.lang.Object nodeV)
Removes the edge connectingnodeU
tonodeV
, if it is present.- Returns:
true
if the graph was modified as a result of this call
-
-