rebuild method

void rebuild({
  1. required Iterable<Node<T>> nodes,
  2. required Iterable<Connection> connections,
  3. required Iterable<Annotation> annotations,
  4. required List<Rect> connectionSegmentCalculator(
    1. Connection
    ),
})

Rebuilds the entire index from the given elements.

Use this after loading a graph or performing major structural changes.

Implementation

void rebuild({
  required Iterable<Node<T>> nodes,
  required Iterable<Connection> connections,
  required Iterable<Annotation> annotations,
  required List<Rect> Function(Connection) connectionSegmentCalculator,
}) {
  clear();
  batch(() {
    for (final node in nodes) {
      update(node);
    }
    for (final connection in connections) {
      final segments = connectionSegmentCalculator(connection);
      updateConnection(connection, segments);
    }
    for (final annotation in annotations) {
      updateAnnotation(annotation);
    }
  });
}