effect-io-ai

Package: effect
Module: Graph

Graph.DijkstraConfig

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

Signature

export interface DijkstraConfig<E> {
  source: NodeIndex
  target: NodeIndex
  cost: (edgeData: E) => number
}

Source

Since v3.18.0