Module 4.9 — Dijkstra & Bellman-Ford with edge relaxation
If going through u gives a shorter path to v, update the distance.