addEdge method

  1. @override
bool addEdge(
  1. Edge<E> edge
)
override

Adds an edge from to the graph.

Returns true if the edge was added, false if it was already 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 of source in successors;
  • If source has no predecessors, return true for containsRoot;

In addition, the graph may, depending on the implementation:

  • Add source and target to the graph if they are not already present;
  • Consider the inverse also an edge, i.e. for undirected graphs.

Implementation

@override
bool addEdge(Edge<E> edge) {
  final a = super.addEdge(edge);
  final b = super.addEdge(edge.reversed);
  assert(a == b, 'Inconsistent undirected edges');
  return a;
}