removeEdge method
void
removeEdge(
- Node parent,
- Node child
)
override
Implementation
@override
void removeEdge(Node parent, Node child) {
if (!containsNode(parent.key)) {
throw StateError('Node "${parent.key}" does not exist in graph (parent)');
}
if (!containsNode(child.key)) {
throw StateError('Node "${child.key}" does not exist in graph (child)');
}
if (!_edges.containsKey(parent) || !_edges[parent]!.contains(child)) {
throw StateError('Edge between "${parent.key}" and "${child.key}" does not exist');
}
_parents.remove(child);
final childSet = _edges[parent]!;
childSet.remove(child);
if (childSet.isEmpty) {
_edges[parent] = <Node>{}; // Оставляем пустой сет вместо удаления
}
_invalidateCache();
}