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 ofNetworkwhich adds mutation methods. When mutation is not required, users should prefer theNetworkinterface.- Since:
- 20.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanaddEdge(N nodeU, N nodeV, E edge)AddsedgeconnectingnodeUtonodeV.booleanaddNode(N node)Addsnodeif it is not already present.booleanremoveEdge(java.lang.Object edge)Removesedgefrom this network, if it is present.booleanremoveNode(java.lang.Object node)Removesnodeif it is present; all edges incident tonodewill 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)
Addsnodeif it is not already present.Nodes must be unique, just as
Mapkeys must be. They must also be non-null.- Returns:
trueif the network was modified as a result of this call
-
addEdge
boolean addEdge(N nodeU, N nodeV, E edge)
AddsedgeconnectingnodeUtonodeV. In an undirected network, the edge will also connectnodeVtonodeU.Edges must be unique, just as
Mapkeys must be. They must also be non-null.Behavior if
nodeUandnodeVare not already present in this network is implementation-dependent. Suggested behaviors include (a) silentlyaddingnodeUandnodeVto the network (this is the behavior of the default implementations) or (b) throwingIllegalArgumentException.If
edgealready connectsnodeUtonodeV(in the specified order if this networkNetwork.isDirected(), else in any order), then this method will have no effect.- Returns:
trueif the network was modified as a result of this call- Throws:
java.lang.IllegalArgumentException- ifedgealready exists and does not connectnodeUtonodeV, or if the introduction of the edge would violateNetwork.allowsParallelEdges()orNetwork.allowsSelfLoops()
-
removeNode
boolean removeNode(java.lang.Object node)
Removesnodeif it is present; all edges incident tonodewill also be removed.- Returns:
trueif the network was modified as a result of this call
-
removeEdge
boolean removeEdge(java.lang.Object edge)
Removesedgefrom this network, if it is present.- Returns:
trueif the network was modified as a result of this call
-
-