line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Algorithm::Graphs::TransitiveClosure::Tiny; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
142024
|
use 5.010; |
|
2
|
|
|
|
|
20
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
65
|
|
5
|
2
|
|
|
2
|
|
23
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
56
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
10
|
use Exporter 'import'; |
|
2
|
|
|
|
|
24
|
|
|
2
|
|
|
|
|
566
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT_OK = qw(floyd_warshall); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.03'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub floyd_warshall { |
15
|
9
|
|
|
9
|
0
|
10388
|
my $graph = shift; |
16
|
9
|
|
|
|
|
21
|
my $delEmpty = !shift; |
17
|
|
|
|
|
|
|
|
18
|
9
|
|
|
|
|
18
|
my @vertices = do { |
19
|
9
|
|
|
|
|
14
|
my %vertices; |
20
|
9
|
|
|
|
|
31
|
foreach my $v (keys(%$graph)) { |
21
|
26
|
100
|
|
|
|
45
|
if (%{$graph->{$v}}) { |
|
26
|
100
|
|
|
|
57
|
|
22
|
24
|
|
|
|
|
38
|
@vertices{$v, keys(%{$graph->{$v}})} = (); |
|
24
|
|
|
|
|
76
|
|
23
|
|
|
|
|
|
|
} elsif ($delEmpty) { |
24
|
1
|
|
|
|
|
4
|
delete $graph->{$v}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
9
|
|
|
|
|
32
|
keys %vertices; |
28
|
|
|
|
|
|
|
}; |
29
|
9
|
|
|
|
|
20
|
foreach my $k (@vertices) { |
30
|
28
|
|
|
|
|
49
|
foreach my $i (@vertices) { |
31
|
106
|
|
|
|
|
172
|
foreach my $j (@vertices) { |
32
|
|
|
|
|
|
|
$graph->{$i}->{$j} = undef if (exists($graph->{$k}) && exists($graph->{$k}->{$j}) && |
33
|
|
|
|
|
|
|
exists($graph->{$i}) && exists($graph->{$i}->{$k}) |
34
|
424
|
100
|
100
|
|
|
1927
|
&& !exists($graph->{$i}->{$j})); |
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
9
|
|
|
|
|
33
|
return $graph; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; # End of Algorithm::Graphs::TransitiveClosure::Tiny |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |