Floyd-Warshall algorithm: Difference between revisions

Content deleted Content added
Thundergnat (talk | contribs)
→‎{{header|Perl 6}}: Add Perl 6 example
Thundergnat (talk | contribs)
m →‎{{header|Perl 6}}: style tweaks
Line 626: Line 626:


<lang perl6>sub Floyd-Warshall (Int $n, @edge) {
<lang perl6>sub Floyd-Warshall (Int $n, @edge) {
my @dist = [Inf xx $n] xx $n;
my @dist = [0, |(Inf xx $n-1)], *.Array.rotate(-1) … !*[*-1];
@dist[$_;$_] = 0 for ^$n;

my @next = [0 xx $n] xx $n;
my @next = [0 xx $n] xx $n;