next up previous contents
Next: Digraphen mit negativen Kantengewichten Up: Kürzeste Pfade Previous: Bellman-Ford-Algorithmus

Floyd's Algorithmus für das All-pairs-shortest-path-Problem

Auch genannt ,,Kleene's Algorithmus``. Dieser Algorithmus ist ein weiteres Beispiel für dynamische Programmierung.

Sei G=(V,E) mit Distanzfunktion d:$A\rightarrow \mathbbm{R}_0^+$ gegeben. Sei o.B.d.A. $V=\{v_1, \ldots, v_n\}$.
Sei cijk:= Länge eines kürzesten Pfades von vi nach vj, der als innerer Knoten (alle bis auf ersten und letzten Knoten) nur Knoten aus $\{v_i,\cdots,v_k\}$ enthält.

algorithm floyd:=


$\ulcorner$co $\forall i: d_{ii}=0$ od for alle (i,j) do cij(0):= dij od ; $1\leq i,j\leq n$for k:=1 to n do for alle (i,j), $1\leq i,j\leq n$ do $c_{ij}^{(k)} := \min\left\{c_{ij}^{(k-1)},\ c_{ik}^{(k-1)}+c_{kj}^{(k-1)}\right\}$ od od $\llcorner$

\fbox {{\bf Laufzeit:} $\mathcal{O}(n^3)$}

Korrektheit:
Zu zeigen: cij(k) des Algorithmus = cijk (damit sind für k=n die Kosten der kürzesten Pfade durch cij(k) gegeben).

Beweis: Richtig für k=0. Induktionsschluß: Ein kürzester Pfad von vi nach vj mit inneren Knoten $\in \{v_1,\ldots,v_{k+1}\}$ enthält entweder vk+1 gar nicht als inneren Knoten, oder er enthält vk+1 genau einmal als inneren Knoten. Im ersten Fall wurde dieser Pfad also bereits für cij(k) betrachtet, hat also Länge $\geq c_{ij}^{(k)}$. Im zweiten Fall setzt er sich aus einem kürzesten Pfad P1 von vi nach vk+1 und einem kürzesten Pfad von P2 von vk+1 nach vj zusammen, wobei alle inneren Knoten von P1 und P2 $\in \{v_1,\ldots,v_k\}$ sind. Also ist die Länge des Pfades =ci,k+1(k)+ck+1,j(k). $\Diamond$



\fbox {\parbox[c]{12.45cm}{\textbf{Satz:}
Floyd's Algorithmus f\uml {u}r das All-pair-shortest-path-Problem
 hat Zeitkomplexit\uml {a}t $\mathcal{O}(n^3)$.
}}


next up previous contents
Next: Digraphen mit negativen Kantengewichten Up: Kürzeste Pfade Previous: Bellman-Ford-Algorithmus
Abbas-Bardia Kabiri-Jarghouyeh
3/3/1999