shortestPath

fun shortestPath(from: Cell, to: Cell, heuristic: (current: Cell, target: Cell) -> Double = GridHeuristics.ZERO): WeightedPath<Cell>?(source)

Shortest weighted path from from to to. Returns the path (including both endpoints) plus total cost, or null if to is unreachable. A self-path returns WeightedPath(listOf(from), 0.0).

With the default zero heuristic this is Dijkstra. Pass a non-trivial heuristic for A*; see GridHeuristics for pre-built admissible heuristics.

Cell costs must be non-negative.