rebuild method

void rebuild({
  1. required Iterable<Node<T>> nodes,
  2. required Iterable<Connection> connections,
  3. 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. Nodes include all node types: regular nodes, GroupNode, CommentNode.

Implementation

void rebuild({
  required Iterable<Node<T>> nodes,
  required Iterable<Connection> connections,
  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);
    }
  });
}