##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
Dijkstra breaks with negative edges. Bellman-Ford handles them and detects negative cycles. You'll learn when to use each algorithm.
(Why you need it)
(Negative edge problem)
(Core building block)
(Relax all edges repeatedly)
(Maximum path length)
(The algorithm)
(Why it's slower)
Knowledge check
(The $n$-th iteration)
(Reachability from cycle)
(CSES 1673)
(Maximum becomes minimum)
(In the original graph)
(Cycle must matter)
(Step-by-step approach)
(Pseudocode walkthrough)
(Trace execution)
(summary)
Knowledge check
(CSES 1197)
(Reconstructing the cycle)
(Inside the cycle)
(Detection and extraction)
(Pseudocode walkthrough)
(Trace execution)
(summary)
Knowledge check
(LeetCode 787)
(Limiting path length)
(Why two arrays matter)
(Modified Bellman-Ford)
(Pseudocode walkthrough)
(Trace execution)
(summary)
Knowledge check
(Queue-based relaxation)
(Queue-based approach)
(Counting relaxations)
(Dijkstra vs Bellman-Ford)
(Detecting profit cycles)
Knowledge check
(Handling link costs)
(What can go wrong)
(Algorithm characteristics)
(What to avoid)
Knowledge check
(How to internalize this)
(What you learned)