//打印出从顶点i到顶点j的一条最短路径,Π是前驱矩阵
πij表示从i到顶点j的一条最短路径上j的前驱
PRINT-ALL-PAIRS-SHORTEST-PATH(
Π, i, j)
1 if i = j
2 then print i
3 else if
πij = NIL
4 then print "no path from" i "to" j "exists"
5 else PRINT-ALL-PAIRS-SHORTEST-PATH(
Π, i,
πij)
6 print j
The Floyd-Warshall algorithm
Transitive closure of a directed graph
Johnson's algorithm for sparse graphs