use strict; use warnings; use Graph::Simple; use Data::Dumper; my $g = Graph::Simple->new ( is_directed => 0, is_weighted => 1); $g->add_edge( 'A', 'B', 200 ); $g->add_edge( 'A', 'C', 700 ); $g->add_edge( 'A', 'D', 700 ); $g->add_edge( 'B', 'C', 500 ); $g->add_edge( 'B', 'D', 500 ); $g->add_edge( 'C', 'D', 600 ); my @path = $g->shortest_path('A', 'D'); print Dumper (\@path); #### $VAR1 = [ 'A', 'B', 'D' ];