RosettaCodeData/Task/Floyd-Warshall-algorithm/Haskell/floyd-warshall-algorithm-5.hs

8 lines
258 B
Haskell

buildPaths d = mapWithKey (\pair s -> s { path = buildPath pair}) d
where
buildPath (i,j)
| i == j = [[j]]
| otherwise = do k <- path $ fromJust $ lookup (i,j) d
p <- buildPath (k,j)
[i : p]