line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Graph::Reader::TGF::CSV; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Pragmas. |
4
|
5
|
|
|
5
|
|
65113
|
use base qw(Graph::Reader::TGF); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
3495
|
|
5
|
5
|
|
|
5
|
|
31
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
167
|
|
6
|
5
|
|
|
5
|
|
25
|
use warnings; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
191
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Modules. |
9
|
5
|
|
|
5
|
|
3852
|
use Error::Pure qw(err); |
|
5
|
|
|
|
|
59788
|
|
|
5
|
|
|
|
|
185
|
|
10
|
5
|
|
|
5
|
|
5640
|
use Text::CSV; |
|
5
|
|
|
|
|
76957
|
|
|
5
|
|
|
|
|
38
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Version. |
13
|
|
|
|
|
|
|
our $VERSION = 0.01; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Edge callback. |
16
|
|
|
|
|
|
|
sub _edge_callback { |
17
|
0
|
|
|
0
|
|
|
my ($self, $graph, $id1, $id2, $edge_label) = @_; |
18
|
0
|
|
|
|
|
|
my $status = $self->{'_csv'}->parse($edge_label); |
19
|
0
|
0
|
|
|
|
|
if (! $status) { |
20
|
0
|
|
|
|
|
|
err 'Cannot parse edge label.', |
21
|
|
|
|
|
|
|
'Error', $self->{'_csv'}->error_input, |
22
|
|
|
|
|
|
|
'String', $edge_label; |
23
|
|
|
|
|
|
|
} |
24
|
0
|
|
|
|
|
|
my %params = map { split m/=/ms, $_ } $self->{'_csv'}->fields; |
|
0
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
foreach my $key (keys %params) { |
26
|
0
|
|
|
|
|
|
$graph->set_edge_attribute($id1, $id2, $key, $params{$key}); |
27
|
|
|
|
|
|
|
} |
28
|
0
|
|
|
|
|
|
return; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Initialization. |
32
|
|
|
|
|
|
|
sub _init { |
33
|
0
|
|
|
0
|
|
|
my ($self, $param_hr) = @_; |
34
|
0
|
|
|
|
|
|
$self->SUPER::_init(); |
35
|
0
|
|
|
|
|
|
$self->{'_csv'} = Text::CSV->new({'binary' => 1}); |
36
|
0
|
0
|
|
|
|
|
if (! $self->{'_csv'}) { |
37
|
0
|
|
|
|
|
|
err 'Cannot create Text::CSV object.', |
38
|
|
|
|
|
|
|
'Error', Text::CSV->error_diag; |
39
|
|
|
|
|
|
|
} |
40
|
0
|
|
|
|
|
|
return; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Vertex callback. |
44
|
|
|
|
|
|
|
sub _vertex_callback { |
45
|
0
|
|
|
0
|
|
|
my ($self, $graph, $id, $vertex_label) = @_; |
46
|
0
|
|
|
|
|
|
my $status = $self->{'_csv'}->parse($vertex_label); |
47
|
0
|
0
|
|
|
|
|
if (! $status) { |
48
|
0
|
|
|
|
|
|
err 'Cannot parse vertex label.', |
49
|
|
|
|
|
|
|
'Error', $self->{'_csv'}->error_input, |
50
|
|
|
|
|
|
|
'String', $vertex_label; |
51
|
|
|
|
|
|
|
} |
52
|
0
|
|
|
|
|
|
my %params = map { split m/=/ms, $_ } $self->{'_csv'}->fields; |
|
0
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
foreach my $key (keys %params) { |
54
|
0
|
|
|
|
|
|
$graph->set_vertex_attribute($id, $key, $params{$key}); |
55
|
|
|
|
|
|
|
} |
56
|
0
|
|
|
|
|
|
return; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |