note
remiah
<p>
Hello [http://perlmonks.org/index.pl?node_id=955048|zing]<br><br>
I was looking at the same Graph module for several days...<br>
I want to ask the same question for directed graph. I wonder if this module lacks for 'list all path', or whether I miss something.<br><br>
You can list all shortest path in your graph, if you do like this.
<code>
use strict;
use warnings;
use Graph;
my @a=qw(a b d);
my @b=qw(c c e);
my $g = Graph->new( undirected => 1 );
for (my $r = 0; $r <= 2; $r++) {
$g->add_edge($a[$r], $b[$r]);
}
#get path from apsp
my $apsp=$g->APSP_Floyd_Warshall();
#...with all pattern using glob
my @v=$g->vertices;
my $ptn=join(",", @v);
for (glob "{$ptn},{$ptn}"){
my($u,$v)=split(/,/, $_);
next if( $u eq $v ); #skip same combination, or ignore self cycle
my @p=$apsp->path_vertices($u,$v);
if (@p){
print join(',', @p), "\n";
}
}
</code>
So, for just listing all path, it may be faster if I do recursive call by myself. I am feeling missing something.
</p>
<p>
I would like to ask for a good way, if you find one.<br>
regards.
</p>
996887
996887