next up previous contents
Next: Floyd's Algorithmus für das Up: Das single-source-shortest-path-Problem Previous: Dikstra's Algorithmus mit Radix-Heaps

Bellman-Ford-Algorithmus

Dieser Algorithmus ist ein Beispiel für dynamische Programmierung.

Sei Bk[i]:= Länge eines kürzesten Pfades von s zu Knoten i, der höchstens k Kanten enthält.
Gesucht ist Bn-1[i]; für $i=1,\cdots, n$, Menge der Knoten $V=\{1,\cdots,n\}$

Initialisierung:

\begin{displaymath}
B_1[i]:=
\left\{ 
\begin{array}
{ll}
 \text{d}(s,i) &, \text...
 ...falls } i=s;\\ +\infty & , \text{sonst}\\ \end{array} 
\right. \end{displaymath}

Iteration:


for k=2 to n-1 do for i=1 to n do $B_k[i]:=
\left\{ 
\begin{array}
{ll}
 0 & , \text{falls } i=s;\\ \min_{j\in N(i...
 ...B_{k-1}[i], B_{k-1}[j]+\text{d}(j,i) \} &, \text{sonst}\\ \end{array} 
\right. $ od od

Korrekheit: klar (Beweis durch vollständige Induktion)

Zeitbedarf: Wenn die innere Laufschleife durch eine Schleife über alle Kanten ersetzt wird:
\fbox {Zeitbedarf: $\mathcal{O}(n\cdot m)$}


Abbas-Bardia Kabiri-Jarghouyeh
3/3/1999