Graph.forEach() method
Visits every vertex once, depth first.
Signature:
forEach(callback: GraphForeachCallback<T>): Graph<T>;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
callback |
Called once per vertex. |
Returns:
Graph<T>
This graph, for chaining.
Remarks
Walks from each vertex in turn, sharing one visited set across all of them — so the callback sees each vertex exactly once no matter how many paths reach it, and a disconnected part of the graph is covered too. A callback returning false prunes that branch; the traversal moves on to the next vertex rather than stopping.