SSSP
Single-Source Shortest Path (SSSP) is a fundamental problem in graph theory. Given a weighted graph G = (V, E) and a designated source vertex s ∈ V, the goal is to determine the length of the shortest path from s to every vertex v ∈ V and often to reconstruct those paths. The computed values form a distance function dist(v) and, optionally, a predecessor function to recover the actual paths. Distances assume that the sum of edge weights along a path is the path length; in directed graphs, the problem is defined similarly with respect to edge direction.
When all edge weights are nonnegative, Dijkstra’s algorithm efficiently computes SSSP from s. Using a priority
The output typically includes dist[] (and sometimes pred[] to reconstruct paths) and may be expressed as a