Map::Metro::Graph - An entire graph
Version 0.2405, released 2016-07-23.
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;
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.
3
1
coderef
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.
$origin_station
$destination_station
Returns a Routing.
Takes no arguments. Returns an array reference of Routings between every combination of Stations.
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.
line_station_id
Call this method after creation if you prefer long startup times but faster searches.
This returns the complete Graph object created from parsing the map.
https://github.com/Csson/p5-Map-Metro
https://metacpan.org/release/Map-Metro
Erik Carlsson <info@code301.com>
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.
To install Map::Metro, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Map::Metro
CPAN shell
perl -MCPAN -e shell install Map::Metro
For more information on module installation, please visit the detailed CPAN module installation guide.