NAME
Graph::RandomPath - Find a random path between two graph vertices
SYNOPSIS
use Graph::RandomPath;
my $generator = Graph::RandomPath->create_generator($g, $from, $to);
say "Vertices on random path 1: ", join ' ', $generator->();
say "Vertices on random path 2: ", join ' ', $generator->();
DESCRIPTION
Generates random paths between two vertices in a Graph.
CLASS METHODS
- create_generator($graph, $start_vertex, $final_vertex, %opt)
-
Returns a reference to a sub routine that returns a list of vertices that describe a path from (inclusive)
$start_vertex
to$final_vertex
(inclusive) in the Graph-compatible object$graph
. The function stores a snapshot of the graph, modifications to the orignal graph are ignored. An exception is raised if no paths can be generated, e.g. when there is no path from$start_vertex
to$final_vertex
at all. The number of vertices in the path determines the length, edge weights are currently ignored.The options hash
%opt
can set the following values:
EXPORTS
None.
CAVEATS
The create_generator
function internally calls SPT_Dijkstra
on a reduced graph containing only reachable vertices. Depending on how the supplied Graph object implements this method it might not work on large graphs due to the algorithmic complexity of the function.
AUTHOR / COPYRIGHT / LICENSE
Copyright (c) 2014 Bjoern Hoehrmann <bjoern@hoehrmann.de>.
This module is licensed under the same terms as Perl itself.