Skip to content

@graphty/algorithms / index / indexed / depthFirstSearch

Function: depthFirstSearch() ​

depthFirstSearch(g, startNode, options?): DfsResult

Defined in: indexed/dfs.ts:162

Depth-first search over out-neighbours, trying them in row (ascending index) order unless options.arcOrder gives another. Takes any AdjacencyView, so s.reverse() walks in-neighbours.

Parameters ​

g ​

AdjacencyView

The adjacency to traverse

startNode ​

NodeRef

The node to start from: its index, or { id }

options? ​

DfsOptions = {}

Traversal options

Returns ​

DfsResult

The visit order, the DFS tree as a parent array, the tree depths and the visited count