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 ofNetwork
which adds mutation methods. When mutation is not required, users should prefer theNetwork
interface.- Since:
- 20.0
- Author:
- James Sexton, Joshua O'Madadhain
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
addEdge(EndpointPair<N> endpoints, E edge)
Addsedge
connectingendpoints
.boolean
addEdge(N nodeU, N nodeV, E edge)
Addsedge
connectingnodeU
tonodeV
.boolean
addNode(N node)
Addsnode
if it is not already present.boolean
removeEdge(E edge)
Removesedge
from this network, if it is present.boolean
removeNode(N 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, edgeConnectingOrNull, edgeConnectingOrNull, edgeOrder, edges, edgesConnecting, edgesConnecting, equals, hasEdgeConnecting, hasEdgeConnecting, hashCode, incidentEdges, incidentNodes, inDegree, inEdges, isDirected, nodeOrder, nodes, outDegree, outEdges, predecessors, successors
-
-
-
-
Method Detail
-
addNode
@CanIgnoreReturnValue 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
@CanIgnoreReturnValue boolean addEdge(N nodeU, N nodeV, E edge)
Addsedge
connectingnodeU
tonodeV
.If the graph is directed,
edge
will be directed in this graph; otherwise, it will be undirected.edge
must be unique to this graph, just as aMap
key must be. It must also be non-null.If
nodeU
andnodeV
are not already present in this graph, this method will silentlyadd
nodeU
andnodeV
to the graph.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:
IllegalArgumentException
- ifedge
already exists in the graph and does not connectnodeU
tonodeV
IllegalArgumentException
- if the introduction of the edge would violateNetwork.allowsParallelEdges()
orNetwork.allowsSelfLoops()
-
addEdge
@CanIgnoreReturnValue boolean addEdge(EndpointPair<N> endpoints, E edge)
Addsedge
connectingendpoints
. In an undirected network,edge
will also connectnodeV
tonodeU
.If this graph is directed,
edge
will be directed in this graph; if it is undirected,edge
will be undirected in this graph.If this graph is directed,
endpoints
must be ordered.edge
must be unique to this graph, just as aMap
key must be. It must also be non-null.If either or both endpoints are not already present in this graph, this method will silently
add
each missing endpoint to the graph.If
edge
already connects an endpoint pair equal toendpoints
, then this method will have no effect.- Returns:
true
if the network was modified as a result of this call- Throws:
IllegalArgumentException
- ifedge
already exists in the graph and connects some other endpoint pair that is not equal toendpoints
IllegalArgumentException
- if the introduction of the edge would violateNetwork.allowsParallelEdges()
orNetwork.allowsSelfLoops()
IllegalArgumentException
- if the endpoints are unordered and the graph is directed- Since:
- 27.1
-
removeNode
@CanIgnoreReturnValue boolean removeNode(N 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
@CanIgnoreReturnValue boolean removeEdge(E edge)
Removesedge
from this network, if it is present.- Returns:
true
if the network was modified as a result of this call
-
-