Import std.algo.search
DijkstraAll
function
@PanicsAtCaller Public Function DijkstraAll<N, C>(start: N, successors: Func(N): (N, C)[]): ShortestPaths<N, C>
The cheapest paths from start to every node it reaches, by Dijkstra's algorithm, with each
step's weight from successors. A negative or NaN weight panics.
Examples
Local roads = {"a": [("b", 7), ("c", 2)], "b": [("d", 1)], "c": [("b", 3), ("d", 8)], "d": []}
Local paths = DijkstraAll("a", Function(town: String) => roads[town])
Expect(paths.CostTo("b") == 5)
Expect(paths.PathTo("d") == ["a", "c", "b", "d"])
Expect(paths.Nodes == ["a", "c", "b", "d"])Report an issue with this page or with FutureBlitz on GitHub.