in reply to what is wrong with my Dijkstram algorithm?
You are not using strict and warnings for starters. Next:
You should chomp it, otherwise $root will contain newline in the end.my $root= <>;
Oh, really?my %graph= %graph;
And this is why you should use strict, note $dist{$n}, shouldn't it be $dist{$n1}?$dist{$n2} = $dist{$n} + $graph{$n1}{$n2};
|
|---|