#!perl use strict; use warnings; my $MAX = 5; # how big my $TO = '3-1'; # from 0-0, where to? use Graph; my $g = Graph->new(); my @from; for my $y ( 0 .. $MAX ) { my @to; for my $x ( 0 .. $y ) { push @to, "$y-$x"; } for my $f ( 0 .. $#from ) { for my $t ( $f .. $f + 1 ) { $g->add_edge( $from[$f], $to[$t] ); } } @from = @to; } # Comment next 3 if no install Graph::Convert and Graph::Easy use Graph::Convert; my $ge = Graph::Convert->as_graph_easy($g); print $ge->as_ascii . "\n"; my $apsp = $g->APSP_Floyd_Warshall(); my @v = $apsp->path_vertices('0-0', $TO); print join ( " ", @v ) . "\n";