This is the core logic. For a neighbor v with edge weight w:
If taking the path through u is shorter than the current best path to v, update it.
if dist[u] + w < dist[v] then
dist[v] := dist[u] + w
pq.push((dist[v], v))
Relaxation improves distance estimates. Eventually, all estimates become exact shortest distances. The greedy order ensures you finalize nodes in shortest-distance order.