Graph.walk() method
Walks depth first from one vertex.
Signature:
walk(vertex: T, callback?: GraphForeachCallback<T>, visited?: Map<T, boolean>): Graph<T>;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
vertex |
T |
Vertex to start from. |
|
callback |
(Optional) Called once per vertex reached; returning | |
|
visited |
Map<T, boolean> |
(Optional) Vertices already reached. A fresh map by default. |
Returns:
Graph<T>
This graph, for chaining.
Remarks
Follows edges as far as they go, marking each vertex as it arrives and never arriving twice, which is what makes it safe on a cyclic graph. Passing a visited map of your own both continues an earlier walk and lets you exclude vertices by marking them before starting.