Interface MutableGraph<N>
- Type Parameters:
N
- Node parameter type
- All Superinterfaces:
Graph<N>, PredecessorsFunction<N>, SuccessorsFunction<N>
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Addsnode
if it is not already present.Network
<N, EndpointPair<N>> Returns a live view of this graph as aNetwork
whose edgesE
areEndpointPair<N>
objects (that is, aNetwork<N, EndpointPair<N>>
).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 interface Graph
adjacentNodes, allowsSelfLoops, degree, edges, equals, hasEdgeConnecting, hasEdgeConnecting, hashCode, incidentEdgeOrder, incidentEdges, inDegree, isDirected, nodeOrder, nodes, outDegree, predecessors, successors
-
Method Details
-
addNode
Addsnode
if it is not already present.Nodes must be unique, just as
Map
keys must be. They must also be non-null.- Returns:
true
if the graph was modified as a result of this call
-
putEdge
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.- Returns:
true
if the graph was modified as a result of this call- Throws:
IllegalArgumentException
- if the introduction of the edge would violateGraph.allowsSelfLoops()
-
putEdge
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.- Returns:
true
if the graph was modified as a result of this call- Throws:
IllegalArgumentException
- if the introduction of the edge would violateGraph.allowsSelfLoops()
IllegalArgumentException
- if the endpoints are unordered and the graph is directed- Since:
- 27.1
-
removeNode
Removesnode
if it is present; all edges incident tonode
will also be removed.- Returns:
true
if the graph was modified as a result of this call
-
removeEdge
Removes the edge connectingnodeU
tonodeV
, if it is present.- Returns:
true
if the graph was modified as a result of this call
-
removeEdge
Removes the edge connectingendpoints
, if it is present.If this graph is directed,
endpoints
must be ordered.- Returns:
true
if the graph was modified as a result of this call- Throws:
IllegalArgumentException
- if the endpoints are unordered and the graph is directed- Since:
- 27.1
-
asNetwork
Network<N, EndpointPair<N>> asNetwork()Returns a live view of this graph as aNetwork
whose edgesE
areEndpointPair<N>
objects (that is, aNetwork<N, EndpointPair<N>>
). The resultingNetwork
's edge-oriented methods (such asinEdges()
) will return views transformed from the corresponding node-oriented methods (such aspredecessors()
).This capability facilitates writing implementations of edge-oriented code.
-