Top Description Fields Constructors Methods
com.google.common.graph

pack-priv final Class StandardMutableNetwork<N, E>

extends StandardNetwork<N, E>
implements MutableNetwork<N, E>
Class Inheritance
All Implemented Interfaces
com.google.common.graph.MutableNetwork, com.google.common.graph.Network, com.google.common.graph.PredecessorsFunction, com.google.common.graph.SuccessorsFunction
Annotations
@ElementTypesAreNonnullByDefault
Type Parameters
<N>
Node parameter type
<E>
Edge parameter type
Static Imports
com.google.common.base.Preconditions.checkArgument, .Preconditions.checkNotNull, .Preconditions.checkState, com.google.common.graph.GraphConstants.PARALLEL_EDGES_NOT_ALLOWED, .GraphConstants.REUSING_EDGE, .GraphConstants.SELF_LOOPS_NOT_ALLOWED, java.util.Objects.requireNonNull

Standard implementation of 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.

Authors
James Sexton, Joshua O'Madadhain, Omar Darwish

Field Summary

Inherited from com.google.common.graph.StandardNetwork:
edgeToReferenceNodenodeConnections

Constructor Summary

AccessConstructor and Description
pack-priv
StandardMutableNetwork(NetworkBuilder<? super N, ? super E> builder)

Constructs a mutable graph with the properties specified in builder.

Method Summary

Modifier and TypeMethod and Description
public boolean
addEdge(N nodeU, N nodeV, E edge)

Implements com.google.common.graph.MutableNetwork.addEdge.

Adds edge connecting nodeU to nodeV.
public boolean
addEdge(EndpointPair<N> endpoints, E edge)

Implements com.google.common.graph.MutableNetwork.addEdge.

Adds edge connecting endpoints.
public boolean
addNode(N node)

Implements com.google.common.graph.MutableNetwork.addNode.

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>
public boolean
removeEdge(E edge)

Implements com.google.common.graph.MutableNetwork.removeEdge.

Removes edge from this network, if it is present.
public boolean
removeNode(N node)

Implements com.google.common.graph.MutableNetwork.removeNode.

Removes node if it is present; all edges incident to node will also be removed.
Inherited from com.google.common.graph.StandardNetwork:
adjacentNodesallowsParallelEdgesallowsSelfLoopscheckedConnectionscheckedReferenceNodecontainsEdgecontainsNodeedgeOrderedgesedgesConnectingincidentEdgesincidentNodesinEdgesisDirectednodeOrdernodesoutEdgespredecessorssuccessors

Constructor Detail

StandardMutableNetworkback to summary
pack-priv StandardMutableNetwork(NetworkBuilder<? super N, ? super E> builder)

Constructs a mutable graph with the properties specified in builder.

Method Detail

addEdgeback to summary
public boolean addEdge(N nodeU, N nodeV, E edge)

Implements com.google.common.graph.MutableNetwork.addEdge.

Doc from com.google.common.graph.MutableNetwork.addEdge.

Adds 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 isDirected(), else in any order), then this method will have no effect.

Returns:boolean

true if the network was modified as a result of this call

Annotations
@Override
@CanIgnoreReturnValue
addEdgeback to summary
public boolean addEdge(EndpointPair<N> endpoints, E edge)

Implements com.google.common.graph.MutableNetwork.addEdge.

Doc from com.google.common.graph.MutableNetwork.addEdge.

Adds 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.

Returns:boolean

true if the network was modified as a result of this call

Annotations
@Override
@CanIgnoreReturnValue
addNodeback to summary
public boolean addNode(N node)

Implements com.google.common.graph.MutableNetwork.addNode.

Doc from com.google.common.graph.MutableNetwork.addNode.

Adds node if it is not already present.

Nodes must be unique, just as Map keys must be. They must also be non-null.

Returns:boolean

true if the network was modified as a result of this call

Annotations
@Override
@CanIgnoreReturnValue
addNodeInternalback to summary
private NetworkConnections<N, E> addNodeInternal(N node)

Adds node to the graph and returns the associated NetworkConnections.

Annotations
@CanIgnoreReturnValue
Exceptions
IllegalStateException:
if node is already present
newConnectionsback to summary
private NetworkConnections<N, E> newConnections()
removeEdgeback to summary
public boolean removeEdge(E edge)

Implements com.google.common.graph.MutableNetwork.removeEdge.

Doc from com.google.common.graph.MutableNetwork.removeEdge.

Removes edge from this network, if it is present.

Returns:boolean

true if the network was modified as a result of this call

Annotations
@Override
@CanIgnoreReturnValue
removeNodeback to summary
public boolean removeNode(N node)

Implements com.google.common.graph.MutableNetwork.removeNode.

Doc from com.google.common.graph.MutableNetwork.removeNode.

Removes node if it is present; all edges incident to node will also be removed.

Returns:boolean

true if the network was modified as a result of this call

Annotations
@Override
@CanIgnoreReturnValue