import { traverseBreadthFirstHashed } from "https://deno.land/x/rimbu@0.13.5/graph/main/traverse/traverse-breadth-first.ts";
Returns a stream of connections that can be reached in the given graph
starting at the given startNode
, and using breadth-first traversal. It avoids
loops by internally placing the visited nodes in a HashSet builder.
Examples
Example 1
Example 1
const g = EdgeGraphHashed.of([1, 2], [2, 3], [1, 3], [3, 4])
const stream = traverseBreadthFirstHashed(g, 1)
console.log(stream.toArray())
// => [[1, 2], [1, 3], [2, 3], [3, 4]]