next up previous contents
Next: Der Algorithmus von Johnson Up: Digraphen mit negativen Kantengewichten Previous: Modifikation von Bellman-Ford-Algorithmus

Modifikation von Floyd's-Algorithmus

Falls kein negativer Kreis existiert, funktioniert der Algorithmus weiterhin korrekt.


\begin{picture}
(50,50)
 \put(5,35){\circle*{2}} 
 \put(25,45){\circle*{2}} 
 \p...
 ...}
 \put(17,12){\makebox(0,0){$1$}}
 \put(8,25){\makebox(0,0){$-6$}}\end{picture}
$\textstyle\parbox{5cm}{
$c_{16}^6 = 5 = c_{16}^5$\space \\ \\ $c_{61}^6 = -6 = c_{61}^5$\space \\ \\ $c_{11}^6 = \min \{c_{11}^5,c_{16}^5+c_{61}^5 \} =-1 $
}$

$ \Rightarrow $ der Graph enthält einen negativen Kreis, g.d.w. ein ciin < 0 existiert.

Man kann also in den Algorithmus von Floyd einen Test auf negative Kreise einbauen, indem man direkt vor der Ausgabe den folgenden Befehl einfügt:


for i 1 to n do if ciin < 0 then stop.



Abbas-Bardia Kabiri-Jarghouyeh
3/3/1999