Skip to content

@graphty/algorithms / index / shortestPathBFS

Function: shortestPathBFS() ​

shortestPathBFS(graph, source, target): ShortestPathResult | null

Defined in: algorithms/traversal/bfs-unified.ts:174

Find shortest path between two nodes using BFS

Automatically optimized for large graphs. Returns null if no path exists.

Parameters ​

graph ​

Graph

The input graph to search

source ​

NodeId

The source node ID

target ​

NodeId

The target node ID

Returns ​

ShortestPathResult | null

Shortest path result or null if no path exists