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