01The problem: shortest paths from one vertex
Given a weighted graph, directed or undirected, where every edge weight is non-negative. Find the shortest distances from a chosen source vertex to all other vertices, and the paths themselves. The algorithm was found by the Dutch scientist Edsger Dijkstra in 1959.
Why not BFS? In the lecture graph, the route from 1 to 6 with the fewest edges (4 of them) costs 23, while a 6-edge route costs only 15. Path length is the sum of weights, not the number of edges.
The lecture lists related problems this one covers:
- to one vertex v from everywhere: reverse every edge and run from v;
- one pair u, v: run from u (nothing faster for a single pair is known);
- all pairs: run from every vertex (Floyd–Warshall is more compact, not asymptotically faster).