Package com.google.common.graph
Interface MutableNetwork<N,E>
-
- Type Parameters:
N- Node parameter typeE- Edge parameter type
- All Superinterfaces:
Network<N,E>,PredecessorsFunction<N>,SuccessorsFunction<N>
@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
- Author:
- James Sexton, Joshua O'Madadhain
-
-
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(E edge)Removesedgefrom this network, 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.Network
adjacentEdges, adjacentNodes, allowsParallelEdges, allowsSelfLoops, asGraph, degree, edgeConnecting, edgeConnectingOrNull, edgeOrder, edges, edgesConnecting, equals, hasEdgeConnecting, 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.If
nodeUandnodeVare not already present in this graph, this method will silentlyaddnodeUandnodeVto the graph.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(N 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(E edge)
Removesedgefrom this network, if it is present.- Returns:
trueif the network was modified as a result of this call
-
-