Type RELAX — the single primitive of all shortest-path algorithms
Type RELAX — the single primitive of all shortest-path algorithms
Answer
if dist[v] > dist[u] + w: dist[v] = dist[u] + w pred[v] = u
Bellman-Ford runs this over every edge |V|−1 times then one detection pass; Dijkstra runs it on edges leaving the extracted-min vertex; DAG-shortest-paths runs it in topological order. The schedule differs; the primitive does not.