为什么 Bellman–Ford 算法需要循环“顶点个数 – 1”次呢?
資深大佬 : JasonLaw 0
下面是我所找到的一些资料:
- shortest path – Why do we need to run the bellman-ford algorithm for n-1 times? – Computer Science Stack Exchange
- graph – Why need (node number – 1) iterations in Bellman Ford algorithm to find shortest paths? – Stack Overflow
但我还是不能够理解 Bellman–Ford 算法。
- 为什么 Bellman–Ford 算法需要循环“顶点个数 – 1”次?
- 每次循环到底保证了什么不变性( invariant )?最后可以帮助证明,经过“顶点个数 – 1”次循环后,能够找到顶点 s 到其他顶点的最短距离。
大佬有話說 (6)