A from-scratch look at how Dijkstra's algorithm finds shortest paths — the relaxation step, why negative weights break it, and a heapq implementation.
Dijkstra's algorithm is the standard greedy approach to shortest-path problems, but the reason it works — and the exact condition under which it stops working — comes down to one operation: relaxation. This paper walks through that core idea, the six-step algorithm built on top of it, and a clean Python implementation using a min-heap.