Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with graph module

Status
Not open for further replies.

ailse

Programmer
Jan 20, 2004
79
GB
hi,

i'm not sure if anyone can help, as I am having a problem with a specific module - called Graph-0.74 (
basically i am trying to use the Graph::AdjacencyMatrix module, for creating and querying an adjacency matrix and also a distance matrix. I can get the adjacency matrix to work fine, but not the distance matrix. If anyone has time to install the module and give me some tips i'd be really grateful!

the code i am using to test the module out is as follows:

Code:
use Graph::Directed;
use Graph::AdjacencyMatrix;
use Data::Dumper;

my $g = Graph::Directed->new;

$g->add_edge("A","B");
$g->add_edge("A","C");
$g->add_edge("B","C");
$g->add_edge("C","D");

my $am = Graph::AdjacencyMatrix->new($g, distance_matrix => 1);

if ($am->is_adjacent("A","B")) {
print "Success\n";
}
else { print "Failed\n"; }

if ($am->is_adjacent("A","D")) {
print "Success\n";
}
else { print "Failed\n"; }

my $dist = $am->distance("A","B");
print Dumper($dist);

I get the expected response for the first two if loops (first Success and then Failed) but the data dumper prints undef for $dist, when I am expecting a value of 1 for distance.

if anyone has any experience of using this module or can work out where i'm going wrong, basically i can get the is_adjacent($u,$v) object method to work but not the distance($u,$v) method.

thanks :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top