zakishah has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to use Paths::Graph in order to find shortest path between nodes, for this i am trying to access txt file to input data , my data contains ip address of node with metric value, but my code is showing error. My txt file is
(10.0.0.128 =>{10.0.0.129=>3,10.0.0.129=>4,10.0.0.130=>3,10.0.0.131=>2 +,10.0.0.132=>1,10.0.0.133=>1,10.0.0.134=>2,10.0.0.135=>4,10.0.0.136=> +1,10.0.0.137=>4,10.0.0.138=>3}, 10.0.0.129 =>{10.0.0.128=>3,10.0.0.130=>1,10.0.0.131=>2,10.0.0.132=>1, +10.0.0.133=>2,10.0.0.134=>1,10.0.0.135=>2,10.0.0.136=3,10.0.0.137=>3, +10.0.0.138=>4}, );
My code is
open FILE, '<', "data.txt" or die $!; my %graph = <FILE> use Paths::Graph; my $g = Paths::Graph->new(-origin=>"10.0.0.128"=>"10.0.0.138",-graph=> +\%graph); my @paths = $g->shortest_path(); for my $path (@paths) { print "Shortest Path:" . join ("->" , @$path) . " Cost:". $g-> +get_path_cost(@$path) ."\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Paths::Graph use
by Khen1950fx (Canon) on Aug 22, 2012 at 03:57 UTC | |
|
Re: Paths::Graph use
by RMGir (Prior) on Aug 22, 2012 at 11:52 UTC | |
by zakishah (Novice) on Aug 22, 2012 at 17:44 UTC | |
by RMGir (Prior) on Aug 23, 2012 at 12:12 UTC | |
by afoken (Chancellor) on Aug 24, 2012 at 04:20 UTC | |
|
Re: Paths::Graph use
by Anonymous Monk on Aug 22, 2012 at 02:51 UTC |