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

pack-priv final Class StandardMutableGraph<N>

extends ForwardingGraph<N>
implements MutableGraph<N>
Class Inheritance
All Implemented Interfaces
com.google.common.graph.MutableGraph, com.google.common.graph.Graph, com.google.common.graph.BaseGraph, com.google.common.graph.PredecessorsFunction, com.google.common.graph.SuccessorsFunction
Annotations
@ElementTypesAreNonnullByDefault
Type Parameters
<N>
Node parameter type
Imports
com.google.common.graph.GraphConstants.Presence

Standard implementation of MutableGraph that supports both directed and undirected graphs. Instances of this class should be constructed with GraphBuilder.

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.

Author
James Sexton

Field Summary

Modifier and TypeField and Description
private final MutableValueGraph<N, GraphConstants.Presence>

Constructor Summary

AccessConstructor and Description
pack-priv
StandardMutableGraph(AbstractGraphBuilder<? super N> builder)

Constructs a MutableGraph with the properties specified in builder.

Method Summary

Modifier and TypeMethod and Description
public boolean
addNode(N node)

Implements com.google.common.graph.MutableGraph.addNode.

Adds node if it is not already present.
pack-priv BaseGraph<N>
public boolean
putEdge(N nodeU, N nodeV)

Implements com.google.common.graph.MutableGraph.putEdge.

Adds an edge connecting nodeU to nodeV if one is not already present.
public boolean
putEdge(EndpointPair<N> endpoints)

Implements com.google.common.graph.MutableGraph.putEdge.

Adds an edge connecting endpoints (in the order, if any, specified by endpoints) if one is not already present.
public boolean
removeEdge(N nodeU, N nodeV)

Implements com.google.common.graph.MutableGraph.removeEdge.

Removes the edge connecting nodeU to nodeV, if it is present.
public boolean
removeEdge(EndpointPair<N> endpoints)

Implements com.google.common.graph.MutableGraph.removeEdge.

Removes the edge connecting endpoints, if it is present.
public boolean
removeNode(N node)

Implements com.google.common.graph.MutableGraph.removeNode.

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

Field Detail

backingValueGraphback to summary
private final MutableValueGraph<N, GraphConstants.Presence> backingValueGraph

Constructor Detail

StandardMutableGraphback to summary
pack-priv StandardMutableGraph(AbstractGraphBuilder<? super N> builder)

Constructs a MutableGraph with the properties specified in builder.

Method Detail

addNodeback to summary
public boolean addNode(N node)

Implements com.google.common.graph.MutableGraph.addNode.

Doc from com.google.common.graph.MutableGraph.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 graph was modified as a result of this call

Annotations
@Override
delegateback to summary
pack-priv BaseGraph<N> delegate()

Implements abstract com.google.common.graph.ForwardingGraph.delegate.

Annotations
@Override
putEdgeback to summary
public boolean putEdge(N nodeU, N nodeV)

Implements com.google.common.graph.MutableGraph.putEdge.

Doc from com.google.common.graph.MutableGraph.putEdge.

Adds an edge connecting nodeU to nodeV if one is not already present.

If the graph is directed, the resultant edge will be directed; otherwise, it will be undirected.

If nodeU and nodeV are not already present in this graph, this method will silently add nodeU and nodeV to the graph.

Returns:boolean

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

Annotations
@Override
putEdgeback to summary
public boolean putEdge(EndpointPair<N> endpoints)

Implements com.google.common.graph.MutableGraph.putEdge.

Doc from com.google.common.graph.MutableGraph.putEdge.

Adds an edge connecting endpoints (in the order, if any, specified by endpoints) if one is not already present.

If this graph is directed, endpoints must be ordered and the added edge will be directed; if it is undirected, the added edge will be undirected.

If this graph is directed, endpoints must be ordered.

If either or both endpoints are not already present in this graph, this method will silently add each missing endpoint to the graph.

Returns:boolean

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

Annotations
@Override
removeEdgeback to summary
public boolean removeEdge(N nodeU, N nodeV)

Implements com.google.common.graph.MutableGraph.removeEdge.

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

Removes the edge connecting nodeU to nodeV, if it is present.

Returns:boolean

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

Annotations
@Override
removeEdgeback to summary
public boolean removeEdge(EndpointPair<N> endpoints)

Implements com.google.common.graph.MutableGraph.removeEdge.

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

Removes the edge connecting endpoints, if it is present.

If this graph is directed, endpoints must be ordered.

Returns:boolean

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

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

Implements com.google.common.graph.MutableGraph.removeNode.

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

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

Returns:boolean

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

Annotations
@Override