Graph Theory37 sections · 1633 units
Open in Course

The Relaxation Step

Updating distances through edges

While the priority queue is not empty:

1.1. Pop the top element {dd, uu}. This is the closest unprocessed node.

2.2. If you have already processed uu (found shorter path earlier), skip it.

3.3. Mark uu as processed.

4.4. For each neighbor vv of uu, try to relax the edge: if going through uu is shorter, update dist[v] and push to the queue. The "skip if processed" check handles duplicates in the priority queue.