N
- Node parameter typefinal class ConfigurableMutableGraph<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 |
---|
ConfigurableMutableGraph(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. |
protected Graph<N> |
delegate() |
boolean |
putEdge(N nodeU,
N nodeV)
Adds an edge connecting
nodeU to nodeV if one is not already present. |
boolean |
removeEdge(java.lang.Object nodeU,
java.lang.Object nodeV)
Removes the edge connecting
nodeU to nodeV , if it is present. |
boolean |
removeNode(java.lang.Object node)
Removes
node if it is present; all edges incident to node will also be removed. |
adjacentNodes, allowsSelfLoops, degree, edges, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successors
edgeCount, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
adjacentNodes, allowsSelfLoops, degree, edges, equals, hashCode, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successors
private final MutableValueGraph<N,GraphConstants.Presence> backingValueGraph
ConfigurableMutableGraph(AbstractGraphBuilder<? super N> builder)
MutableGraph
with the properties specified in builder
.protected Graph<N> delegate()
delegate
in class ForwardingGraph<N>
public boolean addNode(N node)
MutableGraph
node
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)
MutableGraph
nodeU
to nodeV
if one is not already present. In an
undirected graph, the edge will also connect nodeV
to nodeU
.
Behavior if nodeU
and nodeV
are not already present in this graph is
implementation-dependent. Suggested behaviors include (a) silently adding
nodeU
and nodeV
to the graph (this is the behavior of the default
implementations) or (b) throwing IllegalArgumentException
.
putEdge
in interface MutableGraph<N>
true
if the graph was modified as a result of this callpublic boolean removeNode(java.lang.Object node)
MutableGraph
node
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(java.lang.Object nodeU, java.lang.Object nodeV)
MutableGraph
nodeU
to nodeV
, if it is present.removeEdge
in interface MutableGraph<N>
true
if the graph was modified as a result of this call