Class ConfigurableMutableNetwork<N,E>
- java.lang.Object
-
- com.google.common.graph.AbstractNetwork<N,E>
-
- com.google.common.graph.ConfigurableNetwork<N,E>
-
- com.google.common.graph.ConfigurableMutableNetwork<N,E>
-
- Type Parameters:
N
- Node parameter typeE
- Edge parameter type
- All Implemented Interfaces:
MutableNetwork<N,E>
,Network<N,E>
,PredecessorsFunction<N>
,SuccessorsFunction<N>
final class ConfigurableMutableNetwork<N,E> extends ConfigurableNetwork<N,E> implements MutableNetwork<N,E>
Configurable implementation ofMutableNetwork
that supports both directed and undirected graphs. Instances of this class should be constructed withNetworkBuilder
.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 ofnode
.
-
-
Field Summary
-
Fields inherited from class com.google.common.graph.ConfigurableNetwork
edgeToReferenceNode, nodeConnections
-
-
Constructor Summary
Constructors Constructor Description ConfigurableMutableNetwork(NetworkBuilder<? super N,? super E> builder)
Constructs a mutable graph with the properties specified inbuilder
.
-
Method Summary
All Methods Instance Methods Concrete 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.private NetworkConnections<N,E>
addNodeInternal(N node)
Addsnode
to the graph and returns the associatedNetworkConnections
.private NetworkConnections<N,E>
newConnections()
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 class com.google.common.graph.ConfigurableNetwork
adjacentNodes, allowsParallelEdges, allowsSelfLoops, checkedConnections, checkedReferenceNode, containsEdge, containsNode, edgeOrder, edges, edgesConnecting, incidentEdges, incidentNodes, inEdges, isDirected, nodeOrder, nodes, outEdges, predecessors, successors
-
Methods inherited from class com.google.common.graph.AbstractNetwork
adjacentEdges, asGraph, degree, edgeConnecting, edgeConnecting, edgeConnectingOrNull, edgeConnectingOrNull, edgesConnecting, equals, hasEdgeConnecting, hasEdgeConnecting, hashCode, inDegree, isOrderingCompatible, outDegree, toString, validateEndpoints
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.google.common.graph.Network
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
-
-
-
-
Constructor Detail
-
ConfigurableMutableNetwork
ConfigurableMutableNetwork(NetworkBuilder<? super N,? super E> builder)
Constructs a mutable graph with the properties specified inbuilder
.
-
-
Method Detail
-
addNode
public boolean addNode(N node)
Description copied from interface:MutableNetwork
Addsnode
if it is not already present.Nodes must be unique, just as
Map
keys must be. They must also be non-null.- Specified by:
addNode
in interfaceMutableNetwork<N,E>
- Returns:
true
if the network was modified as a result of this call
-
addNodeInternal
private NetworkConnections<N,E> addNodeInternal(N node)
Addsnode
to the graph and returns the associatedNetworkConnections
.- Throws:
java.lang.IllegalStateException
- ifnode
is already present
-
addEdge
public boolean addEdge(N nodeU, N nodeV, E edge)
Description copied from interface:MutableNetwork
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.- Specified by:
addEdge
in interfaceMutableNetwork<N,E>
- Returns:
true
if the network was modified as a result of this call
-
addEdge
public boolean addEdge(EndpointPair<N> endpoints, E edge)
Description copied from interface:MutableNetwork
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.- Specified by:
addEdge
in interfaceMutableNetwork<N,E>
- Returns:
true
if the network was modified as a result of this call
-
removeNode
public boolean removeNode(N node)
Description copied from interface:MutableNetwork
Removesnode
if it is present; all edges incident tonode
will also be removed.- Specified by:
removeNode
in interfaceMutableNetwork<N,E>
- Returns:
true
if the network was modified as a result of this call
-
removeEdge
public boolean removeEdge(E edge)
Description copied from interface:MutableNetwork
Removesedge
from this network, if it is present.- Specified by:
removeEdge
in interfaceMutableNetwork<N,E>
- Returns:
true
if the network was modified as a result of this call
-
newConnections
private NetworkConnections<N,E> newConnections()
-
-