Floyd-Warshall algorithm: Difference between revisions
m
→{{header|Sidef}}: code simplifications
m (→{{header|SequenceL}}: fixing translation link) |
m (→{{header|Sidef}}: code simplifications) |
||
Line 1,055:
{{trans|Ruby}}
<lang ruby>func floyd_warshall(n, edge) {
var dist = n.of {
var nxt = n.of { n.of(nil) }
for u,v,w in edge {
Line 1,062:
}
}
}
var summary = "pair dist path\n"
for i,j
var u
while (u != j)
path.map!{|u| u+1 }.join!(" -> ")▼
summary += ("%d -> %d %4d %s\n" % (i+1, j+1, dist[i][j], path))▼
}
}
|