Bellman-Ford: Difference between revisions
No edit summary |
|||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:Videos]] | |||
[[Category: | |||
[[Category:Algorithm]] | [[Category:Algorithm]] | ||
[[Category:Main Algorithm]] | [[Category:Main Algorithm]] | ||
{{#ev:youtube|https://www.youtube.com/watch?v=3_zqU5GWo4w|500|right|All pairs shortest paths Bellman-Ford|frame}} | |||
==General information== | ==General information== | ||
'''Algorithmic problem:''' [[All pairs shortest paths]] | '''Algorithmic problem:''' [[All pairs shortest paths]] | ||
Line 11: | Line 11: | ||
'''Auxiliary data:''' | '''Auxiliary data:''' | ||
# A | # A real-valued <math>(n \times n)</math> matrix <math>M</math>, where <math>n=|V|</math>. The eventual contents of <math>M</math> will be returned as the result of the algorithm. | ||
# A | # A real-valued <math>(n \times n)</math> matrix <math>L</math>, where <math>n=|V|</math>. This matrix represents the graph and the arc lengths and will not be changed throughout the algorithm. | ||
'''Notation:''' | |||
On this page, <math>M^i</math> refers to the contents of <math>M</math> after <math>i\geq 0</math> iterations. | |||
==Abstract view== | ==Abstract view== |
Latest revision as of 22:51, 19 June 2015
General information
Algorithmic problem: All pairs shortest paths
Prerequisites:
Type of algorithm: loop
Auxiliary data:
- A real-valued
matrix , where . The eventual contents of will be returned as the result of the algorithm. - A real-valued
matrix , where . This matrix represents the graph and the arc lengths and will not be changed throughout the algorithm.
Notation:
On this page,
Abstract view
Invariant: After
Variant:
Break condition:
Induction basis
Abstract view: For all
; if ; , if and .
Induction step
Abstract view: For all
(Note that
Implementation: Obvious.
Correctness: Follows from the fact that a shortest path cannot have more than
Complexity
Statement: The asymptotic complexity is
Proof: The main loop terminates after