Package com.google.common.graph
Interface MutableNetwork<N,E>
-
- Type Parameters:
N
- Node parameter typeE
- Edge parameter type
- All Superinterfaces:
Network<N,E>
@Beta public interface MutableNetwork<N,E> extends Network<N,E>
A subinterface ofNetwork
which adds mutation methods. When mutation is not required, users should prefer theNetwork
interface.- Since:
- 20.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
addEdge(N nodeU, N nodeV, E edge)
Addsedge
connectingnodeU
tonodeV
.boolean
addNode(N node)
Addsnode
if it is not already present.boolean
removeEdge(java.lang.Object edge)
Removesedge
from this network, 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.Network
adjacentEdges, adjacentNodes, allowsParallelEdges, allowsSelfLoops, asGraph, degree, edgeOrder, edges, edgesConnecting, equals, hashCode, incidentEdges, incidentNodes, inDegree, inEdges, isDirected, nodeOrder, nodes, outDegree, outEdges, 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 network was modified as a result of this call
-
addEdge
boolean addEdge(N nodeU, N nodeV, E edge)
Addsedge
connectingnodeU
tonodeV
. In an undirected network, the edge will also connectnodeV
tonodeU
.Edges must be unique, just as
Map
keys must be. They must also be non-null.Behavior if
nodeU
andnodeV
are not already present in this network is implementation-dependent. Suggested behaviors include (a) silentlyadding
nodeU
andnodeV
to the network (this is the behavior of the default implementations) or (b) throwingIllegalArgumentException
.If
edge
already connectsnodeU
tonodeV
(in the specified order if this networkNetwork.isDirected()
, else in any order), then this method will have no effect.- Returns:
true
if the network was modified as a result of this call- Throws:
java.lang.IllegalArgumentException
- ifedge
already exists and does not connectnodeU
tonodeV
, or if the introduction of the edge would violateNetwork.allowsParallelEdges()
orNetwork.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 network was modified as a result of this call
-
removeEdge
boolean removeEdge(java.lang.Object edge)
Removesedge
from this network, if it is present.- Returns:
true
if the network was modified as a result of this call
-
-