NAME
Map::Metro::Graph - An entire graph
VERSION
Version 0.2405, released 2016-07-23.
SYNOPSIS
my $graph = Map::Metro->new('Stockholm')->parse;
my $routing = $graph->routing_for('Universitetet', 'Kista');
# And then it's traversing time. Also see the
# Map::Metro::Plugin::Hook::PrettyPrinter hook
say $routing->origin_station->name;
say $routing->destination_station->name;
foreach my $route ($routing->all_routes) {
foreach my $step ($route->all_steps) {
say 'Transfer!' if $step->was_line_transfer;
say $step->origin_line_station->line->id;
say $step->origin_line_station->station->name;
}
say '----';
}
#* The constructed Graph object is also available
my $full_graph = $graph->full_graph;
DESCRIPTION
This class is at the core of Map::Metro. After a map has been parsed the returned instance of this class contains the entire network (graph) in a hierarchy of objects.
ATTRIBUTES
filepath
default_line_change_weight
Int |
optional, default: 3 |
read-only |
do_undiacritic
Bool |
optional, default: 1 |
read/write |
full_graph
override_line_change_weight
wanted_hook_plugins
ArrayRef [ Str ] |
optional, default is a coderef |
read-only |
asps
not in constructor |
read/write |
connections
emit
Object |
not in constructor |
read-only |
line_stations
lines
routings
segments
stations
transfers
METHODS
routing_for
my $routing = $graph->routing_for($origin_station, $destination_station);
$origin_station
and $destination_station
can be either a station id, a station name or a Station object. Both are required, but they can be of different types.
Returns a Routing.
all_pairs
Takes no arguments. Returns an array reference of Routings between every combination of Stations.
asps
Map::Metro uses Graph under the hood. This method returns the "All-Pairs Shortest Paths (APSP)" in Graph object returned by the APSP_Floyd_Warshall() method. If you prefer to traverse the graph via this object, observe that the vertices is identified by their line_station_id
in Map::Metro::Graph::LineStation.
Call this method after creation if you prefer long startup times but faster searches.
full_graph
This returns the complete Graph object created from parsing the map.
SOURCE
https://github.com/Csson/p5-Map-Metro
HOMEPAGE
https://metacpan.org/release/Map-Metro
AUTHOR
Erik Carlsson <info@code301.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Erik Carlsson.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.