Graph::RandomPath - Find a random path between two graph vertices
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->();
Generates random paths between two vertices in a Graph.
- 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)
$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
$final_vertexat all. The number of vertices in the path determines the length, edge weights are currently ignored.
The options hash
%optcan set the following values:
- max_length => 64
The maximum length for generated paths. The default is
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 <firstname.lastname@example.org>. This module is licensed under the same terms as Perl itself.