line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Graph::Reader - perl base class for Graph file format readers |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Graph::Reader; |
5
|
|
|
|
|
|
|
$Graph::Reader::VERSION = '2.09'; |
6
|
2
|
|
|
2
|
|
792
|
use 5.006; |
|
2
|
|
|
|
|
6
|
|
7
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
42
|
|
8
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
47
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
608
|
use IO::File; |
|
2
|
|
|
|
|
6545
|
|
|
2
|
|
|
|
|
174
|
|
11
|
2
|
|
|
2
|
|
659
|
use Graph; |
|
2
|
|
|
|
|
78889
|
|
|
2
|
|
|
|
|
370
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#======================================================================= |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# new () - constructor |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
#======================================================================= |
18
|
|
|
|
|
|
|
sub new |
19
|
|
|
|
|
|
|
{ |
20
|
1
|
|
|
1
|
1
|
17
|
my $class = shift; |
21
|
1
|
|
|
|
|
2
|
my %args = @_; |
22
|
|
|
|
|
|
|
|
23
|
1
|
50
|
|
|
|
9
|
die "don't create an instance of $class!\n" if $class eq __PACKAGE__; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
$self->_init(\%args); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
#======================================================================= |
33
|
|
|
|
|
|
|
# |
34
|
|
|
|
|
|
|
# _init() - initialise instance |
35
|
|
|
|
|
|
|
# |
36
|
|
|
|
|
|
|
# This is for any instance-specific initialisation. The idea is that |
37
|
|
|
|
|
|
|
# a sub-class will define an _init() method if it needs one. |
38
|
|
|
|
|
|
|
# For future compatibility the class-specific method should invoke |
39
|
|
|
|
|
|
|
# this. |
40
|
|
|
|
|
|
|
# |
41
|
|
|
|
|
|
|
#======================================================================= |
42
|
|
|
|
|
|
|
sub _init |
43
|
|
|
|
0
|
|
|
{ |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#======================================================================= |
47
|
|
|
|
|
|
|
# |
48
|
|
|
|
|
|
|
# read_graph() - create a Graph and read the given file into it |
49
|
|
|
|
|
|
|
# |
50
|
|
|
|
|
|
|
# This is the public method that will be invoked to read a graph. |
51
|
|
|
|
|
|
|
# The file can be specified either as a filename, or a filehandle. |
52
|
|
|
|
|
|
|
# |
53
|
|
|
|
|
|
|
#======================================================================= |
54
|
|
|
|
|
|
|
sub read_graph |
55
|
|
|
|
|
|
|
{ |
56
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
57
|
0
|
|
|
|
|
|
my $filename = shift; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $graph = Graph->new(); |
60
|
0
|
|
|
|
|
|
my $FILE; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
if (ref $filename) |
64
|
|
|
|
|
|
|
{ |
65
|
0
|
|
|
|
|
|
$self->_read_graph($graph, $filename); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
else |
68
|
|
|
|
|
|
|
{ |
69
|
0
|
|
|
|
|
|
$FILE = IO::File->new("< $filename"); |
70
|
0
|
0
|
|
|
|
|
if (not defined $FILE) |
71
|
|
|
|
|
|
|
{ |
72
|
0
|
|
|
|
|
|
warn "couldn't read from $filename: $!\n"; |
73
|
0
|
|
|
|
|
|
return 0; |
74
|
|
|
|
|
|
|
} |
75
|
0
|
|
|
|
|
|
$self->_read_graph($graph, $FILE); |
76
|
0
|
|
|
|
|
|
$FILE->close(); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return $graph; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |