Skip to content

@graphty/algorithms / index / breadthFirstSearch

Function: breadthFirstSearch() ​

breadthFirstSearch(g, startNode, options?): BfsResult

Defined in: indexed/bfs.ts:172

Breadth-first search over out-neighbours. Takes any AdjacencyView, so s.reverse() gives an in-neighbour BFS with no extra code.

Parameters ​

g ​

AdjacencyView

The adjacency to traverse

startNode ​

NodeRef

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

options? ​

BfsOptions = {}

Traversal options

Returns ​

BfsResult

The visit order, the parent array, the depth array and the visited count