Algorithm::ScheduledPath::Path - Path class for Algorithm::ScheduledPath


NAME

Algorithm::ScheduledPath::Path - Path class for Algorithm::ScheduledPath


DESCRIPTION

This is a class for managine paths (ordered sets of edges) in the Algorithm::ScheduledPath manpage.

Methods

new
  $path = new Algorithm::ScheduledPath::Path( @edges );

Creates a new pathand adds edges if they are specified (see add_edge).

add_edge
  $path->add_edge( $edge );

Adds an edge to the path (see the Algorithm::ScheduledPath::Edge manpage).

The path must be connected, so the origin of the edge to be added must be the same as the destination of the path.

first_edge
  $edge = $path->first_edge;

Returns the first edge in the path.

origin
  $orig = $path->origin;

Returns the origin of the path.

last_edge
  $edge = $path->last_edge;

Returns the last edge of the path.

destination
  $dest = $path->destination;

Returns the destination of the path.

depart_time
  $time = $path->depart_time;

Returns the departure time from the origin.

arrive_time
  $time = $path->arrive_time;

Returns the arrival time at the destination.

travel_time
  $time = $path->travel_time;

Returns the total travel time (arrival time - depart time).

get_edges
  @edges = @{ $path->get_edges };

Returns a reference to an array containing the component the Algorithm::ScheduledPath::Edge manpage objects.

size
  $size = $path->size;

Returns the number of edges in the path.

has_vertex
  if ($path->has_vertex('LEV')) { ... }

Returns true if a path passes through a given vertex.

has_cycle
  if ($path->has_cycle) { ... }

Returns true if the path has a "cycle" (that is, if it passes through the same vertex more than once).

compressed
  $cpath = $path->compressed;

Produces a "compressed" version of the path, where sequential edges sharing the same path identifier are merged. The result may be a path with "virtual" edges.

For instance, if the path represents a route one might take on a bus line, where the path identifier refers to bus routes, then the compressed version would merge bus stops on the same route so as to make it easier to identify where one needs to transfer to different bus lines. (One could also use this to facilitate analysis of the number of transfers.)

If one of the edges contains a data attribute, then it may not be copied. You will see a warning if it is not copied.

clone
  $path2 = $path->clone;

Clones the path.


AUTHOR

Robert Rothenberg <rrwo at cpan.org>


LICENSE

Copyright (c) 2004 Robert Rothenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


SEE ALSO

Algorithm::ScheduledPath