Why it matters

Dijkstra is greedy classic. Understanding shapes graph search.

Advertisement

The architecture

Extract min-dist vertex.

Relax outgoing edges.

Mark visited; repeat.

Dijkstra greedyMin PQby tentative distanceExtract + relaxoutgoing edgesMark visitedrepeatRequires non-negative edges; for negatives use Bellman-Ford
Dijkstra.
Advertisement

How it works end to end

Non-negative edges required.

Binary heap: O((V+E) log V).

Fibonacci heap: O(E + V log V).