Top Description Methods
com.google.common.graph

public Interface MutableNetwork<N, E>

extends Network<N, E>
Known Direct Implementers
com.google.common.graph.StandardMutableNetwork
Annotations
@Beta
@ElementTypesAreNonnullByDefault
Type Parameters
<N>
Node parameter type
<E>
Edge parameter type
Imports
com.google.common.annotations.Beta, com.google.errorprone.annotations.CanIgnoreReturnValue

A subinterface of Network which adds mutation methods. When mutation is not required, users should prefer the Network interface.
Authors
James Sexton, Joshua O'Madadhain
Since
20.0

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the network was modified as a result of this call
addEdge
(N nodeU, N nodeV, E edge)

Adds edge connecting nodeU to nodeV.

public boolean

Returns:

true if the network was modified as a result of this call
addEdge
(EndpointPair<N> endpoints, E edge)

Adds edge connecting endpoints.

public boolean

Returns:

true if the network was modified as a result of this call
addNode
(N node)

Adds node if it is not already present.

public boolean

Returns:

true if the network was modified as a result of this call
removeEdge
(E edge)

Removes edge from this network, if it is present.

public boolean

Returns:

true if the network was modified as a result of this call
removeNode
(N node)

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

Inherited from com.google.common.graph.Network:
adjacentEdgesadjacentNodesallowsParallelEdgesallowsSelfLoopsasGraphdegreeedgeConnectingedgeConnectingedgeConnectingOrNulledgeConnectingOrNulledgeOrderedgesedgesConnectingedgesConnectingequalshasEdgeConnectinghasEdgeConnectinghashCodeincidentEdgesincidentNodesinDegreeinEdgesisDirectednodeOrdernodesoutDegreeoutEdgespredecessorssuccessors

Method Detail

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

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
@CanIgnoreReturnValue
Exceptions
IllegalArgumentException:
addEdgeback to summary
public boolean addEdge(EndpointPair<N> endpoints, E edge)

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
@CanIgnoreReturnValue
Exceptions
IllegalArgumentException:
  • if edge already exists in the graph and connects some other endpoint pair that is not equal to endpoints
  • if the introduction of the edge would violate allowsParallelEdges() or allowsSelfLoops()
  • if the endpoints are unordered and the graph is directed
Since
27.1
addNodeback to summary
public boolean addNode(N node)

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
@CanIgnoreReturnValue
removeEdgeback to summary
public boolean removeEdge(E edge)

Removes edge from this network, if it is present.

Returns:boolean

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

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

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
@CanIgnoreReturnValue