dfs
dfs<
TNode>(root,traits):boolean
Defined in: graph/dfs.ts:54
Walks a graph or tree of unknown shape depth-first, in pre-order.
The structure is not required to conform to any shared node interface:
childrenOf is the only thing that has to know how a given TNode exposes
its successors, which lets one generic walker drive discriminated unions
whose node kinds carry children under entirely different field names.
Time complexity: O(V + E). Without DfsTraits.seen, a cyclic graph does
not terminate — pass a Set whenever a cycle is possible.
Type Parameters
Section titled “Type Parameters”TNode
Parameters
Section titled “Parameters”TNode
The node to start walking from.
traits
Section titled “traits”DfsTraits<TNode>
How to traverse, and what to do at each node.
Returns
Section titled “Returns”boolean
true if the walk was stopped early via DfsWalkStop,
false if it ran to completion.