Class StandardMutableGraph<N>
- Type Parameters:
N
- Node parameter type
- All Implemented Interfaces:
BaseGraph<N>
,Graph<N>
,MutableGraph<N>
,PredecessorsFunction<N>
,SuccessorsFunction<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
.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStandardMutableGraph
(AbstractGraphBuilder<? super N> builder) Constructs aMutableGraph
with the properties specified inbuilder
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Addsnode
if it is not already present.delegate()
boolean
putEdge
(EndpointPair<N> endpoints) Adds an edge connectingendpoints
(in the order, if any, specified byendpoints
) if one is not already present.boolean
Adds an edge connectingnodeU
tonodeV
if one is not already present.boolean
removeEdge
(EndpointPair<N> endpoints) Removes the edge connectingendpoints
, if it is present.boolean
removeEdge
(N nodeU, N nodeV) Removes the edge connectingnodeU
tonodeV
, if it is present.boolean
removeNode
(N node) Removesnode
if it is present; all edges incident tonode
will also be removed.Methods inherited from class com.google.common.graph.ForwardingGraph
adjacentNodes, allowsSelfLoops, degree, edgeCount, hasEdgeConnecting, hasEdgeConnecting, incidentEdgeOrder, incidentEdges, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successors
Methods inherited from class com.google.common.graph.AbstractGraph
equals, hashCode, toString
Methods inherited from class com.google.common.graph.AbstractBaseGraph
edges, isOrderingCompatible, nodeInvalidatableSet, nodePairInvalidatableSet, validateEndpoints
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.google.common.graph.Graph
adjacentNodes, allowsSelfLoops, degree, edges, equals, hasEdgeConnecting, hasEdgeConnecting, hashCode, incidentEdgeOrder, incidentEdges, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successors
-
Field Details
-
backingValueGraph
-
-
Constructor Details
-
StandardMutableGraph
StandardMutableGraph(AbstractGraphBuilder<? super N> builder) Constructs aMutableGraph
with the properties specified inbuilder
.
-
-
Method Details
-
delegate
- Specified by:
delegate
in classForwardingGraph<N>
-
addNode
Description copied from interface:MutableGraph
Addsnode
if it is not already present.Nodes must be unique, just as
Map
keys must be. They must also be non-null.- Specified by:
addNode
in interfaceMutableGraph<N>
- Returns:
true
if the graph was modified as a result of this call
-
putEdge
Description copied from interface:MutableGraph
Adds an edge connectingnodeU
tonodeV
if one is not already present.If the graph is directed, the resultant edge will be directed; otherwise, it will be undirected.
If
nodeU
andnodeV
are not already present in this graph, this method will silentlyadd
nodeU
andnodeV
to the graph.- Specified by:
putEdge
in interfaceMutableGraph<N>
- Returns:
true
if the graph was modified as a result of this call
-
putEdge
Description copied from interface:MutableGraph
Adds an edge connectingendpoints
(in the order, if any, specified byendpoints
) 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.- Specified by:
putEdge
in interfaceMutableGraph<N>
- Returns:
true
if the graph was modified as a result of this call
-
removeNode
Description copied from interface:MutableGraph
Removesnode
if it is present; all edges incident tonode
will also be removed.- Specified by:
removeNode
in interfaceMutableGraph<N>
- Returns:
true
if the graph was modified as a result of this call
-
removeEdge
Description copied from interface:MutableGraph
Removes the edge connectingnodeU
tonodeV
, if it is present.- Specified by:
removeEdge
in interfaceMutableGraph<N>
- Returns:
true
if the graph was modified as a result of this call
-
removeEdge
Description copied from interface:MutableGraph
Removes the edge connectingendpoints
, if it is present.If this graph is directed,
endpoints
must be ordered.- Specified by:
removeEdge
in interfaceMutableGraph<N>
- Returns:
true
if the graph was modified as a result of this call
-