addEdge method
Adds an edge to the graph. If the graph is undirected, the method automatically creates the opponent edge.
Implementation
Graph addEdge(Edge edge ) {
List<Edge>? edges = _edges[edge.from];
edges?.add( edge );
if ( digraph == false ) {
final oppositeEdge = edge.clone();
oppositeEdge.from = edge.to;
oppositeEdge.to = edge.from;
edges = _edges[edge.to];
edges?.add( oppositeEdge );
}
return this;
}