N - Node parameter typeV - Value parameter typefinal class StandardMutableValueGraph<N,V> extends StandardValueGraph<N,V> implements MutableValueGraph<N,V>
MutableValueGraph that supports both directed and undirected
graphs. Instances of this class should be constructed with ValueGraphBuilder.
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.
| Modifier and Type | Field and Description |
|---|---|
private ElementOrder<N> |
incidentEdgeOrder |
edgeCount, nodeConnections| Constructor and Description |
|---|
StandardMutableValueGraph(AbstractGraphBuilder<? super N> builder)
Constructs a mutable graph with the properties specified in
builder. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addNode(N node)
Adds
node if it is not already present. |
private GraphConnections<N,V> |
addNodeInternal(N node)
Adds
node to the graph and returns the associated GraphConnections. |
ElementOrder<N> |
incidentEdgeOrder()
Returns an
ElementOrder that specifies the order of iteration for the elements of
BaseGraph.edges(), BaseGraph.adjacentNodes(Object), BaseGraph.predecessors(Object), BaseGraph.successors(Object) and BaseGraph.incidentEdges(Object). |
private GraphConnections<N,V> |
newConnections() |
V |
putEdgeValue(EndpointPair<N> endpoints,
V value)
Adds an edge connecting
endpoints if one is not already present, and sets a value for
that edge to value (overwriting the existing value, if any). |
V |
putEdgeValue(N nodeU,
N nodeV,
V value)
Adds an edge connecting
nodeU to nodeV if one is not already present, and sets
a value for that edge to value (overwriting the existing value, if any). |
V |
removeEdge(EndpointPair<N> endpoints)
Removes the edge connecting
endpoints, if it is present. |
V |
removeEdge(N nodeU,
N nodeV)
Removes the edge connecting
nodeU to nodeV, if it is present. |
boolean |
removeNode(N node)
Removes
node if it is present; all edges incident to node will also be removed. |
adjacentNodes, allowsSelfLoops, containsNode, edgeCount, edgeValueOrDefault, edgeValueOrDefault, hasEdgeConnecting, hasEdgeConnecting, incidentEdges, isDirected, nodeOrder, nodes, predecessors, successorsasGraph, edgeValue, edgeValue, equals, hashCode, toStringdegree, edges, inDegree, isOrderingCompatible, outDegree, validateEndpointsclone, finalize, getClass, notify, notifyAll, wait, wait, waitadjacentNodes, allowsSelfLoops, asGraph, degree, edges, edgeValue, edgeValue, edgeValueOrDefault, edgeValueOrDefault, equals, hasEdgeConnecting, hasEdgeConnecting, hashCode, incidentEdges, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successorsprivate final ElementOrder<N> incidentEdgeOrder
StandardMutableValueGraph(AbstractGraphBuilder<? super N> builder)
builder.public ElementOrder<N> incidentEdgeOrder()
BaseGraphElementOrder that specifies the order of iteration for the elements of
BaseGraph.edges(), BaseGraph.adjacentNodes(Object), BaseGraph.predecessors(Object), BaseGraph.successors(Object) and BaseGraph.incidentEdges(Object).incidentEdgeOrder in interface BaseGraph<N>incidentEdgeOrder in interface ValueGraph<N,V>incidentEdgeOrder in class AbstractBaseGraph<N>public boolean addNode(N node)
MutableValueGraphnode if it is not already present.
Nodes must be unique, just as Map keys must be. They must also be non-null.
addNode in interface MutableValueGraph<N,V>true if the graph was modified as a result of this callprivate GraphConnections<N,V> addNodeInternal(N node)
node to the graph and returns the associated GraphConnections.java.lang.IllegalStateException - if node is already present@CheckForNull public V putEdgeValue(N nodeU, N nodeV, V value)
MutableValueGraphnodeU to nodeV if one is not already present, and sets
a value for that edge to value (overwriting the existing value, if any).
If the graph is directed, the resultant edge will be directed; otherwise, it will be undirected.
Values do not have to be unique. However, values must 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.
putEdgeValue in interface MutableValueGraph<N,V>nodeU to nodeV, or null if there was no such edge.@CheckForNull public V putEdgeValue(EndpointPair<N> endpoints, V value)
MutableValueGraphendpoints if one is not already present, and sets a value for
that edge to value (overwriting the existing value, if any).
If the graph is directed, the resultant edge will be directed; otherwise, it will be undirected.
If this graph is directed, endpoints must be ordered.
Values do not have to be unique. However, values must 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.
putEdgeValue in interface MutableValueGraph<N,V>nodeU to nodeV, or null if there was no such edge.public boolean removeNode(N node)
MutableValueGraphnode if it is present; all edges incident to node will also be removed.removeNode in interface MutableValueGraph<N,V>true if the graph was modified as a result of this call@CheckForNull public V removeEdge(N nodeU, N nodeV)
MutableValueGraphnodeU to nodeV, if it is present.removeEdge in interface MutableValueGraph<N,V>nodeU to nodeV, or null if there was no such edge.@CheckForNull public V removeEdge(EndpointPair<N> endpoints)
MutableValueGraphendpoints, if it is present.
If this graph is directed, endpoints must be ordered.
removeEdge in interface MutableValueGraph<N,V>endpoints, or null if
there was no such edge.private GraphConnections<N,V> newConnections()