Subject: | SSSP_Dijkstra does not work |
The following simple code does not work with Graph-0.201, perl 5.6.1, Solaris 8:
use Graph::Undirected;
use strict;
my $g=new Graph::Undirected;
my $d;
$g->add_weighted_edge("r1", 1, "l1");
$d=$g->SSSP_Dijkstra("r1");
print($g, "\n");
print($d, "\n");
It prints:
r1=l1
l1,r1
instead of
r1=l1
r1=l1
or something like this.
The following patch solves this problem:
--- Base.pm.old Thu Oct 14 16:27:44 1999
+++ Base.pm Tue Apr 23 17:54:01 2002
@@ -2036,6 +2036,8 @@
my @path = ( $u );
if ( defined $P->{ $u } ) {
+ $SSSP->add_edge($P->{ $u }, $u );
+ $SSSP->set_attribute( "weight", $P->{ $u }, $u, $G->get_attribute("weight",$P->{ $u }, $u) || 0 );
push @path, $P->{ $u };
if ( $P->{ $u } ne $s ) {
my $v = $P->{ $u };
Unfortunately there is an other problem with the Dijkstra method: it hangs if the graph is not connected. I currently do not have any patches for this problem.