Crawler<E> typedef Graphs

Crawler<E> = Iterable<T> Function<T extends E>(WalkableBase<T> nodes, {required T start, Tracer<T>? tracer})

A function that visits nodes in a graph structure starting from start.

Every algorithm that provides generalizable graph traversals can implement this interface to provide a consistent API for visiting and finding reachable nodes in a graph-like structure (e.g., a graph, tree, or grid, or any WalkableBase implementation).

The exact order, and whether nodes are visited more than once, is algorithm-specific.

Tracing

May provide a tracer to capture finer-detail events during the traversal.

If omitted, no tracing is performed.

Example

final graph = Graph<int>();

graph.addEdge(Edge(1, 2));
graph.addEdge(Edge(2, 3));

final reachable = depthFirst(graph, start: 1);
print(reachable); // (1, 2, 3)

Implementation

typedef Crawler<E> = Iterable<T> Function<T extends E>(
  WalkableBase<T> nodes, {
  required T start,
  Tracer<T>? tracer,
});