line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Map::Tube::Graph; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Pragmas. |
4
|
3
|
|
|
3
|
|
423882
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
81
|
|
5
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
91
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Modules. |
8
|
3
|
|
|
3
|
|
2371
|
use Class::Utils qw(set_params); |
|
3
|
|
|
|
|
69845
|
|
|
3
|
|
|
|
|
66
|
|
9
|
3
|
|
|
3
|
|
190
|
use English; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
21
|
|
10
|
3
|
|
|
3
|
|
1576
|
use Error::Pure qw(err); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
108
|
|
11
|
3
|
|
|
3
|
|
2327
|
use Graph; |
|
3
|
|
|
|
|
304595
|
|
|
3
|
|
|
|
|
116
|
|
12
|
3
|
|
|
3
|
|
21
|
use List::MoreUtils qw(none); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
38
|
|
13
|
3
|
|
|
3
|
|
1381
|
use Scalar::Util qw(blessed); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1833
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Version. |
16
|
|
|
|
|
|
|
our $VERSION = 0.05; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Constructor. |
19
|
|
|
|
|
|
|
sub new { |
20
|
7
|
|
|
7
|
1
|
469955
|
my ($class, @params) = @_; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Create object. |
23
|
7
|
|
|
|
|
19
|
my $self = bless {}, $class; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Edge callback. |
26
|
|
|
|
|
|
|
$self->{'callback_edge'} = sub { |
27
|
63
|
|
|
63
|
|
103
|
my ($self, $node, $link) = @_; |
28
|
63
|
|
|
|
|
186
|
$self->{'graph'}->add_edge($node->id, $link); |
29
|
63
|
|
|
|
|
2561
|
return; |
30
|
7
|
|
|
|
|
48
|
}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Vertex callback. |
33
|
|
|
|
|
|
|
$self->{'callback_vertex'} = sub { |
34
|
61
|
|
|
61
|
|
207
|
my ($self, $node) = @_; |
35
|
61
|
|
|
|
|
194
|
$self->{'graph'}->add_vertex($node->id); |
36
|
61
|
|
|
|
|
1686
|
return; |
37
|
7
|
|
|
|
|
31
|
}; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Graph object. |
40
|
7
|
|
|
|
|
13
|
$self->{'graph'} = undef; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Map::Tube object. |
43
|
7
|
|
|
|
|
17
|
$self->{'tube'} = undef; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Process params. |
46
|
7
|
|
|
|
|
33
|
set_params($self, @params); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Check Map::Tube object. |
49
|
5
|
100
|
|
|
|
71
|
if (! defined $self->{'tube'}) { |
50
|
1
|
|
|
|
|
4
|
err "Parameter 'tube' is required."; |
51
|
|
|
|
|
|
|
} |
52
|
4
|
50
|
|
|
|
15
|
if (! defined &UNIVERSAL::DOES) { |
53
|
0
|
|
|
|
|
0
|
eval { |
54
|
0
|
|
|
|
|
0
|
require UNIVERSAL::DOES; |
55
|
|
|
|
|
|
|
}; |
56
|
0
|
0
|
|
|
|
0
|
if ($EVAL_ERROR) { |
57
|
0
|
|
|
|
|
0
|
err 'Cannot load UNIVERSAL::DOES module.'; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
4
|
100
|
66
|
|
|
72
|
if (! blessed($self->{'tube'}) |
61
|
|
|
|
|
|
|
|| ! $self->{'tube'}->DOES('Map::Tube')) { |
62
|
|
|
|
|
|
|
|
63
|
2
|
|
|
|
|
41
|
err "Parameter 'tube' must be 'Map::Tube' object."; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Graph object. |
67
|
2
|
100
|
|
|
|
81
|
if (! defined $self->{'graph'}) { |
68
|
1
|
|
|
|
|
11
|
$self->{'graph'} = Graph->new; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Object. |
72
|
2
|
|
|
|
|
297
|
return $self; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Get graph. |
76
|
|
|
|
|
|
|
sub graph { |
77
|
1
|
|
|
1
|
1
|
1317
|
my $self = shift; |
78
|
1
|
|
|
|
|
2
|
foreach my $node (values %{$self->{'tube'}->nodes}) { |
|
1
|
|
|
|
|
11
|
|
79
|
61
|
|
|
|
|
113
|
$self->{'callback_vertex'}->($self, $node); |
80
|
|
|
|
|
|
|
} |
81
|
1
|
|
|
|
|
2
|
my @processed; |
82
|
1
|
|
|
|
|
3
|
foreach my $node (values %{$self->{'tube'}->nodes}) { |
|
1
|
|
|
|
|
10
|
|
83
|
61
|
|
|
|
|
182
|
foreach my $link (split m/,/ms, $node->link) { |
84
|
122
|
100
|
|
|
|
464
|
if (none { |
85
|
3788
|
50
|
100
|
3788
|
|
15332
|
($_->[0] eq $node->id && $_->[1] eq $link) |
|
|
|
66
|
|
|
|
|
86
|
|
|
|
|
|
|
|| |
87
|
|
|
|
|
|
|
($_->[0] eq $link && $_->[1] eq $node->id) |
88
|
|
|
|
|
|
|
} @processed) { |
89
|
|
|
|
|
|
|
|
90
|
63
|
|
|
|
|
132
|
$self->{'callback_edge'}->($self, $node, $link); |
91
|
63
|
|
|
|
|
305
|
push @processed, [$node->id, $link]; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
1
|
|
|
|
|
21
|
return $self->{'graph'}; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |