next up previous
Next: Up: Previous:

Pseudocode

Given the predecessor matrix $\Pi$, we can print the shortest path from i to j:

Print-Path($\Pi$, i, j)
$\;\;\;\;\;$if i = j
$\;\;\;\;\;$then print i
$\;\;\;\;\;$else if \(\pi_{i,j}\) = NIL
$\;\;\;\;\;$ $\;\;\;\;\;$then print ``no path exists from i to j''
$\;\;\;\;\;$ $\;\;\;\;\;$else Print-Path($\Pi$, i, \(\pi_{i,j}\))
$\;\;\;\;\;$ $\;\;\;\;\;$ $\;\;\;\;\;$print j


next up previous
Next: Up: Previous: