line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
18
|
use 5.10.0; |
|
2
|
|
|
|
|
4
|
|
2
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
31
|
|
3
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
88
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Map::Metro::Graph::Connection; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Connects two stations on a line |
8
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY |
9
|
|
|
|
|
|
|
our $VERSION = '0.2404'; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
6
|
use Map::Metro::Elk; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
13
|
|
12
|
2
|
|
|
2
|
|
2767
|
use Types::Standard qw/Maybe Int/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
37
|
|
13
|
2
|
|
|
2
|
|
1285
|
use Map::Metro::Types qw/LineStation Connection/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
14
|
|
14
|
2
|
|
|
2
|
|
1465
|
use PerlX::Maybe qw/maybe/; |
|
2
|
|
|
|
|
2404
|
|
|
2
|
|
|
|
|
354
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has origin_line_station => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
isa => LineStation, |
19
|
|
|
|
|
|
|
required => 1, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
has destination_line_station => ( |
22
|
|
|
|
|
|
|
is => 'ro', |
23
|
|
|
|
|
|
|
isa => LineStation, |
24
|
|
|
|
|
|
|
required => 1, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
has previous_connection => ( |
27
|
|
|
|
|
|
|
is => 'rw', |
28
|
|
|
|
|
|
|
isa => Maybe[ Connection ], |
29
|
|
|
|
|
|
|
predicate => 1, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
has next_connection => ( |
32
|
|
|
|
|
|
|
is => 'rw', |
33
|
|
|
|
|
|
|
isa => Maybe[ Connection ], |
34
|
|
|
|
|
|
|
predicate => 1, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
has weight => ( |
37
|
|
|
|
|
|
|
is => 'ro', |
38
|
|
|
|
|
|
|
isa => Int, |
39
|
|
|
|
|
|
|
required => 1, |
40
|
|
|
|
|
|
|
default => 1, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub to_hash { |
44
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
return { |
47
|
0
|
0
|
|
|
|
|
origin_line_station => $self->origin_line_station->to_hash, |
|
|
0
|
|
|
|
|
|
48
|
|
|
|
|
|
|
destination_line_station => $self->destination_line_station->to_hash, |
49
|
|
|
|
|
|
|
maybe previous_connection => $self->has_previous_connection ? $self->previous_connection->to_hash : undef, |
50
|
|
|
|
|
|
|
maybe next_connection => $self->has_next_connection ? $self->next_connection->to_hash : undef, |
51
|
|
|
|
|
|
|
weight => $self->weight, |
52
|
|
|
|
|
|
|
}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=pod |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=encoding UTF-8 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 NAME |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Map::Metro::Graph::Connection - Connects two stations on a line |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 VERSION |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Version 0.2404, released 2016-04-30. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 DESCRIPTION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Connections represent the combination of two specific L<LineStations|Map::Metro::Graph::LineStation>, and the 'cost' of |
76
|
|
|
|
|
|
|
travelling between them. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
In L<Graph> terms, a connection is a weighted edge. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 SOURCE |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
L<https://github.com/Csson/p5-Map-Metro> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 HOMEPAGE |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
L<https://metacpan.org/release/Map-Metro> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 AUTHOR |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Erik Carlsson <info@code301.com> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Erik Carlsson. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
97
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |