Skip to content

@graphty/algorithms / index / dijkstraPath

Function: dijkstraPath() ​

dijkstraPath(graph, source, target, options): ShortestPathResult | null

Defined in: algorithms/shortest-path/dijkstra.ts:128

Find shortest path between two specific nodes using optimized Dijkstra's algorithm

Uses bidirectional search by default for improved performance on point-to-point queries. Automatically falls back to standard Dijkstra for very small graphs or when explicitly disabled.

Parameters ​

graph ​

Graph

The graph to search

source ​

NodeId

The starting node for the path

target ​

NodeId

The destination node for the path

options ​

DijkstraOptions = {}

Algorithm options including bidirectional search toggle

Returns ​

ShortestPathResult | null

The shortest path result or null if no path exists