Package: effect
Module: Graph
Configuration for finding a shortest path with Dijkstra’s algorithm.
When to use
Use when configuring dijkstra to find a shortest path between two existing
node indices with non-negative edge costs.
Details
Specifies the source and target node indices, plus a cost function that maps
each edge’s data to a non-negative numeric weight. Infinity is allowed and
behaves like an impassable edge.
Gotchas
dijkstra throws a GraphError when either endpoint does not exist or when
the cost function returns a negative weight or NaN.
See
dijkstra for the algorithm that consumes this configurationAstarConfig for heuristic shortest-path searchBellmanFordConfig for shortest paths that may include negative edge weightsSignature
export interface DijkstraConfig<E> {
source: NodeIndex
target: NodeIndex
cost: (edgeData: E) => number
}
Since v3.18.0