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
|
|
48
|
use strict; |
|
7
|
|
|
|
|
74
|
|
|
7
|
|
|
|
|
215
|
|
7
|
7
|
|
|
7
|
|
35
|
use warnings; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
2998
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
133
|
|
|
133
|
1
|
278
|
my ($class, $g) = @_; |
11
|
133
|
|
|
|
|
336
|
my @V = $g->vertices; |
12
|
133
|
|
|
|
|
286
|
my $V = @V; |
13
|
133
|
|
|
|
|
200
|
my %V; @V{ @V } = 0 .. $#V; |
|
133
|
|
|
|
|
581
|
|
14
|
133
|
|
|
|
|
1092
|
bless [ [ map [], 0 .. $#V ], \%V ], $class; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub set { |
18
|
1536
|
|
|
1536
|
1
|
2677
|
my ($m, $u, $v, $val) = @_; |
19
|
1536
|
|
|
|
|
3874
|
my ($i, $j) = map $m->[1]->{ $_ }, ($u, $v); |
20
|
1536
|
|
|
|
|
3902
|
$m->[0]->[$i]->[$j] = $val; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub get { |
24
|
3125
|
|
|
3125
|
1
|
5375
|
my ($m, $u, $v) = @_; |
25
|
3125
|
|
|
|
|
7963
|
my ($i, $j) = map $m->[1]->{ $_ }, ($u, $v); |
26
|
3125
|
|
|
|
|
8079
|
$m->[0]->[$i]->[$j]; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub stringify { |
30
|
2
|
|
|
2
|
1
|
6
|
my ($m) = @_; |
31
|
2
|
|
|
|
|
6
|
my @V = sort keys %{ $m->[1] }; |
|
2
|
|
|
|
|
18
|
|
32
|
2
|
|
|
|
|
22
|
my $top = join ' ', map sprintf('%4s', $_), 'to:', @V; |
33
|
2
|
|
|
|
|
12
|
my @indices = map $m->[1]{$_}, @V; |
34
|
2
|
|
|
|
|
3
|
my @rows; |
35
|
2
|
|
|
|
|
10
|
for my $n (@V) { |
36
|
12
|
|
|
|
|
23
|
my $this_row = $m->[0][ $m->[1]->{$n} ]; |
37
|
12
|
|
|
|
|
39
|
my @vals = map $this_row->[ $_ ], @indices; |
38
|
12
|
100
|
|
|
|
111
|
push @rows, join ' ', map sprintf('%4s', defined()?$_:''), $n, @vals; |
39
|
|
|
|
|
|
|
} |
40
|
2
|
|
|
|
|
26
|
join '', map "$_\n", $top, @rows; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
__END__ |