line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Graph::Matrix; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $SIG{__DIE__ } = \&Graph::__carp_confess; |
4
|
|
|
|
|
|
|
# $SIG{__WARN__} = \&Graph::__carp_confess; |
5
|
|
|
|
|
|
|
|
6
|
7
|
|
|
7
|
|
44
|
use strict; |
|
7
|
|
|
|
|
63
|
|
|
7
|
|
|
|
|
215
|
|
7
|
7
|
|
|
7
|
|
37
|
use warnings; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
3124
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
133
|
|
|
133
|
1
|
285
|
my ($class, $g) = @_; |
11
|
133
|
|
|
|
|
301
|
my @V = $g->vertices; |
12
|
133
|
|
|
|
|
257
|
my $V = @V; |
13
|
133
|
|
|
|
|
176
|
my %V; @V{ @V } = 0 .. $#V; |
|
133
|
|
|
|
|
565
|
|
14
|
133
|
|
|
|
|
1137
|
bless [ [ map [], 0 .. $#V ], \%V ], $class; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub set { |
18
|
1535
|
|
|
1535
|
1
|
2855
|
my ($m, $u, $v, $val) = @_; |
19
|
1535
|
|
|
|
|
4104
|
my ($i, $j) = map $m->[1]->{ $_ }, ($u, $v); |
20
|
1535
|
|
|
|
|
4244
|
$m->[0]->[$i]->[$j] = $val; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub get { |
24
|
3125
|
|
|
3125
|
1
|
5016
|
my ($m, $u, $v) = @_; |
25
|
3125
|
|
|
|
|
7684
|
my ($i, $j) = map $m->[1]->{ $_ }, ($u, $v); |
26
|
3125
|
|
|
|
|
8375
|
$m->[0]->[$i]->[$j]; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub stringify { |
30
|
2
|
|
|
2
|
1
|
5
|
my ($m) = @_; |
31
|
2
|
|
|
|
|
6
|
my @V = sort keys %{ $m->[1] }; |
|
2
|
|
|
|
|
15
|
|
32
|
2
|
|
|
|
|
21
|
my $top = join ' ', map sprintf('%4s', $_), 'to:', @V; |
33
|
2
|
|
|
|
|
13
|
my @indices = map $m->[1]{$_}, @V; |
34
|
2
|
|
|
|
|
4
|
my @rows; |
35
|
2
|
|
|
|
|
7
|
for my $n (@V) { |
36
|
12
|
|
|
|
|
24
|
my $this_row = $m->[0][ $m->[1]->{$n} ]; |
37
|
12
|
|
|
|
|
39
|
my @vals = map $this_row->[ $_ ], @indices; |
38
|
12
|
100
|
|
|
|
117
|
push @rows, join ' ', map sprintf('%4s', defined()?$_:''), $n, @vals; |
39
|
|
|
|
|
|
|
} |
40
|
2
|
|
|
|
|
33
|
join '', map "$_\n", $top, @rows; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
__END__ |