Skip Menu |

This queue is for tickets about the Graph CPAN distribution.

Report information
The Basics
Id: 71793
Status: resolved
Priority: 0/
Queue: Graph

People
Owner: Nobody in particular
Requestors: torta [...] di.unito.it
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.94
Fixed in: (no value)



Subject: Problem with APSP and default weight 1
as shown in the attached script: - I define a graph with vertices a,b,c and two edges (a,b) (length 0) and (b,c) (length 1) - I compute the all-pairs-shortest-paths with Floyd-Warshall - I ask for the length of the shortest path between a and c I get 2 instead of 1. I guess this has to do with the fact that "If no weight is defined for an edge, 1 (one) is assumed". However, I have explicitly defined the weight of (a,b) to be 0, so I would expect that the default does not apply. My problem is that I need to define some 0-length and compute the APSP. thank you
Subject: weight.pl
use Graph; use feature say; my $g = new Graph(); $g->add_vertex('a'); $g->add_vertex('b'); $g->add_vertex('c'); $g->add_weighted_edge('a','b',0); $g->add_weighted_edge('b','c',1); my $apsp = $g->APSP_Floyd_Warshall; my $w = $apsp->path_length('a','c'); say $w;
The weight in the APSP (Floyd-Warshall) is a distance, or a cost. A distance of zero does not mean "this edge does not exist" or "do not use this edge": instead it means "these vertices are essentially the same", or "this edge is free", which means that the edge is very eagerly used. If you do not want to have the edge, you need to delete it. I will add some clarifying language to this effect.