NAME

Map::Tube - A very simple perl interface to the London Tube Map.

VERSION

Version 0.05

SYNOPSIS

Here is sample map

    1 --------  2 
   /  \       /  \
  /    \     /    \
 /      \   /      \
0 ------  6 ------- 3
 \      /   \      /
  \    /     \    /
   \  /       \  / 
    5 -------- 4 
   /
  /
 /  
7
 \
  \
   \
    8 
   

which can be defined as below:

{ 0 => [1,5,6], 1 => [0,2,6], 2 => [1,3,6], 3 => [2,4,6], 4 => [3,5,6], 5 => [0,4,6,7], 6 => [0,1,2,3,4,5], 7 => [5,8], 8 => [7],};

Example

  use Map::Tube;
  my $map = Map::Tube->new();
  my @route = $map->get_shortest_route('Bond Street', 'Euston');
  print "Shortest route from 'Bond Street' to 'Euston': " . join(" => ",@route) . "\n";  
  my $map   = Map::Tube->new({from => 5, to => 2});
  my @route = $map->get_shortest_route();

  Output:
  Shortest route from Bond Street to Euston: Bond Street => Oxford Circus => Warren Street => Euston

CONSTRUCTOR

The constructor expects an optional debug flag which is 0(false) by default.

METHODS

get_shortest_route()

This method accepts FROM and TO node name. It is case sensitive at the moment. However I would make it case-insensitive very soon. It returns back the node sequence from FROM to TO.

show_map_chart()

This method takes no parameter. It prints map chart to STDOUT generated while looking for shortest route. It has three columns by the title "N" - Node Code, "P" - Path to here and "L" - Length to reach "N" from "P". At the moment it dumps node code used internally, however, I would change that to dump real node name instead soon.

get_nodes()

Returns all the node's map defintions.

get_elements()

Returns all the elements i.e. node defintions.

_process_node

This is an internal method of the module, which takes FROM node code only. This assumes all the node definitions are defined and map chart has been initialized.

_initialize_table()

This is an internal method and it simply initialize the map chart. It takes nodes definition as reference to a hash and return the table, which is also reference to a hash.

_get_name()

This is an internal method and not exposed to the outside world. It takes node code and gives us full name of the node. It is only called from the method get_shortest_route().

AUTHOR

Mohammad S Anwar, <mohammad.anwar@yahoo.com>

BUGS

Please report any bugs or feature requests to bug-map-tube@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Map-Tube. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Map::Tube

You can also look for information at:

LICENSE AND COPYRIGHT

Copyright 2010 Mohammad S Anwar.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.