Floyd-Warshall(W) n = rows(W) D^{(0)} = W for k = 1 to n for i = 1 to n for j = 1 to n return D^{(n)}