addEdge abstract method
- WeightedGraph<
V> edge
Adds an edge
from source
to target
with a weight
to the graph.
Returns the previous weight of the edge, or null
if the edge was not
present.
If the edge was added, the graph must:
- Add the edge to the graph so that containsEdge returns
true
; - Yield
target
as a successor ofsource
in successors; - If
source
has no predecessors, returntrue
for containsRoot;
In addition, the graph may, depending on the implementation:
- Add
source
andtarget
to the graph if they are not already present; - Consider the inverse also an edge, i.e. for undirected graphs.
Implementation
double? addEdge(WeightedGraph<V> edge);