N - Node parameter typefinal class StandardMutableGraph<N> extends ForwardingGraph<N> implements MutableGraph<N>
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.
| Modifier and Type | Field and Description |
|---|---|
private MutableValueGraph<N,GraphConstants.Presence> |
backingValueGraph |
| Constructor and Description |
|---|
StandardMutableGraph(AbstractGraphBuilder<? super N> builder)
Constructs a
MutableGraph with the properties specified in builder. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addNode(N node)
Adds
node if it is not already present. |
(package private) BaseGraph<N> |
delegate() |
boolean |
putEdge(EndpointPair<N> endpoints)
Adds an edge connecting
endpoints (in the order, if any, specified by endpoints) if one is not already present. |
boolean |
putEdge(N nodeU,
N nodeV)
Adds an edge connecting
nodeU to nodeV if one is not already present. |
boolean |
removeEdge(EndpointPair<N> endpoints)
Removes the edge connecting
endpoints, if it is present. |
boolean |
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, degree, edgeCount, hasEdgeConnecting, hasEdgeConnecting, incidentEdgeOrder, incidentEdges, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successorsequals, hashCode, toStringedges, isOrderingCompatible, validateEndpointsclone, finalize, getClass, notify, notifyAll, wait, wait, waitadjacentNodes, allowsSelfLoops, degree, edges, equals, hasEdgeConnecting, hasEdgeConnecting, hashCode, incidentEdgeOrder, incidentEdges, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successorsprivate final MutableValueGraph<N,GraphConstants.Presence> backingValueGraph
StandardMutableGraph(AbstractGraphBuilder<? super N> builder)
MutableGraph with the properties specified in builder.BaseGraph<N> delegate()
delegate in class ForwardingGraph<N>public boolean addNode(N node)
MutableGraphnode 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 MutableGraph<N>true if the graph was modified as a result of this callpublic boolean putEdge(N nodeU, N nodeV)
MutableGraphnodeU 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.
putEdge in interface MutableGraph<N>true if the graph was modified as a result of this callpublic boolean putEdge(EndpointPair<N> endpoints)
MutableGraphendpoints (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.
putEdge in interface MutableGraph<N>true if the graph was modified as a result of this callpublic boolean removeNode(N node)
MutableGraphnode if it is present; all edges incident to node will also be removed.removeNode in interface MutableGraph<N>true if the graph was modified as a result of this callpublic boolean removeEdge(N nodeU, N nodeV)
MutableGraphnodeU to nodeV, if it is present.removeEdge in interface MutableGraph<N>true if the graph was modified as a result of this callpublic boolean removeEdge(EndpointPair<N> endpoints)
MutableGraphendpoints, if it is present.
If this graph is directed, endpoints must be ordered.
removeEdge in interface MutableGraph<N>true if the graph was modified as a result of this call