getDescendants method
Returns all events transitively caused by eventId (excluding itself).
Uses breadth-first traversal. The order is by graph distance from the origin event.
Implementation
List<CausalEvent> getDescendants(String eventId) {
final result = <CausalEvent>[];
final queue = <String>[eventId];
final visited = <String>{eventId};
while (queue.isNotEmpty) {
final current = queue.removeAt(0);
final children = _childEdges[current] ?? [];
for (final childId in children) {
if (visited.contains(childId)) continue;
visited.add(childId);
final event = _nodes[childId];
if (event != null) {
result.add(event);
queue.add(childId);
}
}
}
return result;
}