Import std.algo.search
Bfs
function
Public Function Bfs<N: Hashable>(start: N, successors: Func(N): N[], goal: Func(N): Bool): N[]?
The path with the fewest steps from start to the first node that goal says is one, by
breadth-first search, or Null when none it reaches is.
Examples
// The numbers, each leading to its double and to one more than it.
Local next = Function(n: Int): Int[] => [n * 2, n + 1]
Expect(Bfs(1, next, Function(n: Int) => n == 10) == [1, 2, 4, 5, 10])Report an issue with this page or with FutureBlitz on GitHub.