GraphForeachCallback type
Called once per vertex during a traversal.
Signature:
export type GraphForeachCallback<T> = (vertex: T, visited: Map<T, boolean>) => false | void;
Remarks
Returning false prunes the walk at that vertex — its own edges are not followed — rather than ending the traversal. Anything else, undefined included, carries on. The second argument is the live visited map, so a callback can see what has already been reached, and add to it to steer the walk away from a vertex it does not want visited.