Package com.google.common.graph
Class ConfigurableMutableValueGraph<N,V>
- java.lang.Object
-
- com.google.common.graph.AbstractGraph<N>
-
- com.google.common.graph.AbstractValueGraph<N,V>
-
- com.google.common.graph.ConfigurableValueGraph<N,V>
-
- com.google.common.graph.ConfigurableMutableValueGraph<N,V>
-
- Type Parameters:
N- Node parameter typeV- Value parameter type
- All Implemented Interfaces:
Graph<N>,MutableValueGraph<N,V>,ValueGraph<N,V>
final class ConfigurableMutableValueGraph<N,V> extends ConfigurableValueGraph<N,V> implements MutableValueGraph<N,V>
Configurable implementation ofMutableValueGraphthat supports both directed and undirected graphs. Instances of this class should be constructed withValueGraphBuilder.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.ConfigurableValueGraph
edgeCount, nodeConnections
-
-
Constructor Summary
Constructors Constructor Description ConfigurableMutableValueGraph(AbstractGraphBuilder<? super N> builder)Constructs a mutable graph with the properties specified inbuilder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddNode(N node)Addsnodeif it is not already present.private GraphConnections<N,V>addNodeInternal(N node)Addsnodeto the graph and returns the associatedGraphConnections.private GraphConnections<N,V>newConnections()VputEdgeValue(N nodeU, N nodeV, V value)Adds an edge connectingnodeUtonodeVif one is not already present; associate that edge withvalue.VremoveEdge(java.lang.Object nodeU, java.lang.Object nodeV)Removes the edge connectingnodeUtonodeV, if it is present.booleanremoveNode(java.lang.Object node)Removesnodeif it is present; all edges incident tonodewill also be removed.-
Methods inherited from class com.google.common.graph.ConfigurableValueGraph
adjacentNodes, allowsSelfLoops, checkedConnections, containsNode, edgeCount, edgeValueOrDefault, isDirected, nodeOrder, nodes, predecessors, successors
-
Methods inherited from class com.google.common.graph.AbstractValueGraph
edgeValue, toString
-
Methods inherited from class com.google.common.graph.AbstractGraph
degree, edges, inDegree, outDegree
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.google.common.graph.Graph
adjacentNodes, allowsSelfLoops, degree, edges, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successors
-
Methods inherited from interface com.google.common.graph.ValueGraph
edgeValue, edgeValueOrDefault, equals, hashCode
-
-
-
-
Constructor Detail
-
ConfigurableMutableValueGraph
ConfigurableMutableValueGraph(AbstractGraphBuilder<? super N> builder)
Constructs a mutable graph with the properties specified inbuilder.
-
-
Method Detail
-
addNode
public boolean addNode(N node)
Description copied from interface:MutableValueGraphAddsnodeif it is not already present.Nodes must be unique, just as
Mapkeys must be. They must also be non-null.- Specified by:
addNodein interfaceMutableValueGraph<N,V>- Returns:
trueif the graph was modified as a result of this call
-
addNodeInternal
private GraphConnections<N,V> addNodeInternal(N node)
Addsnodeto the graph and returns the associatedGraphConnections.- Throws:
java.lang.IllegalStateException- ifnodeis already present
-
putEdgeValue
public V putEdgeValue(N nodeU, N nodeV, V value)
Description copied from interface:MutableValueGraphAdds an edge connectingnodeUtonodeVif one is not already present; associate that edge withvalue. In an undirected graph, the edge will also connectnodeVtonodeU.Values do not have to be unique. However, values must be non-null.
Behavior if
nodeUandnodeVare not already present in this graph is implementation-dependent. Suggested behaviors include (a) silentlyaddingnodeUandnodeVto the graph (this is the behavior of the default implementations) or (b) throwingIllegalArgumentException.- Specified by:
putEdgeValuein interfaceMutableValueGraph<N,V>- Returns:
- the value previously associated with the edge connecting
nodeUtonodeV, or null if there was no such edge.
-
removeNode
public boolean removeNode(java.lang.Object node)
Description copied from interface:MutableValueGraphRemovesnodeif it is present; all edges incident tonodewill also be removed.- Specified by:
removeNodein interfaceMutableValueGraph<N,V>- Returns:
trueif the graph was modified as a result of this call
-
removeEdge
public V removeEdge(java.lang.Object nodeU, java.lang.Object nodeV)
Description copied from interface:MutableValueGraphRemoves the edge connectingnodeUtonodeV, if it is present.- Specified by:
removeEdgein interfaceMutableValueGraph<N,V>- Returns:
- the value previously associated with the edge connecting
nodeUtonodeV, or null if there was no such edge.
-
newConnections
private GraphConnections<N,V> newConnections()
-
-