addEdges method

void addEdges(
  1. T vertex,
  2. Set<T> connectedVertices
)

Adds edges (connections) pointing from vertex to connectedVertices.

Implementation

void addEdges(T vertex, Set<T> connectedVertices) {
  if (_edges.containsKey(vertex)) {
    _edges[vertex]!.addAll(connectedVertices);
  } else {
    // If vertex is new add it to the graph.
    _edges[vertex] = Set.of(connectedVertices);
  }
  for (final connectedVertex in connectedVertices) {
    // If connectedVertex is new add it to the graph.
    _edges[connectedVertex] ??= <T>{};
  }
  updateCache();
}