Loading topic
(u, v, w) is. You should also understand the single-source shortest path problem from the previous chapter. Every algorithm in this tutorial is built from one small operation called edge relaxation. Bellman-Ford, F5 min readn - 1 times. That number comes from a proof about what each round guarantees, and this chapter walks through it. The proof also explains when you need fewer rounds, when you need every one of them, and why the guarantee fails once a negative cycle is present.5 min readpred array that Bellman-Ford fills in becomes a full path. It covers the edge cases that break naive code, and it shows how to pull the ne5 min readd_k[i][j] is the shortest i-to-j distance when only vertices 0..k may appear as intermediate stops. You should also be comfortable with Python lists of lists and with math.inf. Here we turn the recurren5 min read