N
- Node parameter typeE
- Edge parameter typefinal class ConfigurableMutableNetwork<N,E> extends ConfigurableNetwork<N,E> implements MutableNetwork<N,E>
MutableNetwork
that supports both directed and undirected
graphs. Instances of this class should be constructed with NetworkBuilder
.
Time complexities for mutation methods are all O(1) except for removeNode(N node)
,
which is in O(d_node) where d_node is the degree of node
.
edgeToReferenceNode, nodeConnections
Constructor and Description |
---|
ConfigurableMutableNetwork(NetworkBuilder<? super N,? super E> builder)
Constructs a mutable graph with the properties specified in
builder . |
Modifier and Type | Method and Description |
---|---|
boolean |
addEdge(EndpointPair<N> endpoints,
E edge)
Adds
edge connecting endpoints . |
boolean |
addEdge(N nodeU,
N nodeV,
E edge)
Adds
edge connecting nodeU to nodeV . |
boolean |
addNode(N node)
Adds
node if it is not already present. |
private NetworkConnections<N,E> |
addNodeInternal(N node)
Adds
node to the graph and returns the associated NetworkConnections . |
private NetworkConnections<N,E> |
newConnections() |
boolean |
removeEdge(E edge)
Removes
edge from this network, if it is present. |
boolean |
removeNode(N node)
Removes
node if it is present; all edges incident to node will also be removed. |
adjacentNodes, allowsParallelEdges, allowsSelfLoops, checkedConnections, checkedReferenceNode, containsEdge, containsNode, edgeOrder, edges, edgesConnecting, incidentEdges, incidentNodes, inEdges, isDirected, nodeOrder, nodes, outEdges, predecessors, successors
adjacentEdges, asGraph, degree, edgeConnecting, edgeConnecting, edgeConnectingOrNull, edgeConnectingOrNull, edgesConnecting, equals, hasEdgeConnecting, hasEdgeConnecting, hashCode, inDegree, isOrderingCompatible, outDegree, toString, validateEndpoints
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
adjacentEdges, adjacentNodes, allowsParallelEdges, allowsSelfLoops, asGraph, degree, edgeConnecting, edgeConnecting, edgeConnectingOrNull, edgeConnectingOrNull, edgeOrder, edges, edgesConnecting, edgesConnecting, equals, hasEdgeConnecting, hasEdgeConnecting, hashCode, incidentEdges, incidentNodes, inDegree, inEdges, isDirected, nodeOrder, nodes, outDegree, outEdges, predecessors, successors
ConfigurableMutableNetwork(NetworkBuilder<? super N,? super E> builder)
builder
.public boolean addNode(N node)
MutableNetwork
node
if it is not already present.
Nodes must be unique, just as Map
keys must be. They must also be non-null.
addNode
in interface MutableNetwork<N,E>
true
if the network was modified as a result of this callprivate NetworkConnections<N,E> addNodeInternal(N node)
node
to the graph and returns the associated NetworkConnections
.java.lang.IllegalStateException
- if node
is already presentpublic boolean addEdge(N nodeU, N nodeV, E edge)
MutableNetwork
edge
connecting nodeU
to nodeV
.
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 a Map
key must be. It must
also be non-null.
If nodeU
and nodeV
are not already present in this graph, this method will
silently add
nodeU
and nodeV
to the graph.
If edge
already connects nodeU
to nodeV
(in the specified order if
this network Network.isDirected()
, else in any order), then this method will have no effect.
addEdge
in interface MutableNetwork<N,E>
true
if the network was modified as a result of this callpublic boolean addEdge(EndpointPair<N> endpoints, E edge)
MutableNetwork
edge
connecting endpoints
. In an undirected network, edge
will
also connect nodeV
to nodeU
.
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 a Map
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 to endpoints
, then this
method will have no effect.
addEdge
in interface MutableNetwork<N,E>
true
if the network was modified as a result of this callpublic boolean removeNode(N node)
MutableNetwork
node
if it is present; all edges incident to node
will also be removed.removeNode
in interface MutableNetwork<N,E>
true
if the network was modified as a result of this callpublic boolean removeEdge(E edge)
MutableNetwork
edge
from this network, if it is present.removeEdge
in interface MutableNetwork<N,E>
true
if the network was modified as a result of this callprivate NetworkConnections<N,E> newConnections()