Skip to content

DfsTraits

DfsTraits<TNode> = object

Defined in: graph/dfs.ts:14

TNode

childrenOf: (node) => Iterable<TNode> | undefined

Defined in: graph/dfs.ts:16

Returns the successors of a node, or undefined/empty for a leaf.

TNode

Iterable<TNode> | undefined


optional onEnter?: (node) => DfsWalkControl | undefined

Defined in: graph/dfs.ts:22

Called on entering a node, before its children. Returning undefined is treated as DfsWalkContinue.

TNode

DfsWalkControl | undefined


optional onExit?: (node) => void

Defined in: graph/dfs.ts:29

Called on leaving a node, after its children — including when the walk is stopping, so a caller undoing state applied in onEnter always gets the matching call.

TNode

void


optional seen?: Set<TNode>

Defined in: graph/dfs.ts:35

Marks nodes already visited, for a cyclic graph. Omit for a tree, where no node is reachable twice and the bookkeeping would be wasted.