next up previous
Next: Up: Previous:

Pseudocode

\(1. \;\;\) Floyd-Warshall(W)
\(2. \;\;\;\;\;\;\) n = rows(W)
\(3. \;\;\;\;\;\;\)D(0) = W
\(4. \;\;\;\;\;\;\) for k = 1 to n
\(5. \;\;\;\;\;\;\;\;\;\) for i = 1 to n
\(6. \;\;\;\;\;\;\;\;\;\;\;\;\) for j = 1 to n
\(7. \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\) \(d_{ij}^{(k)} \;=\;
min(d_{ij}^{(k-1)}, \;d_{ik}^{(k-1)} \;+\; d_{kj}^{(k-1)})\)
\(8. \;\;\;\;\;\;\) return D(n)

Floyd-Warshall Applet


next up previous
Next: Up: Previous: