Subject: | problem with SPT_Bellman_Ford |
Hi Jarkko
SPT_Bellman_Ford reduces the number of vertices on an undirected,
connected graph. Try running the attached script. I don't think that
should happen?
Daniel
Subject: | test_graph.pl |
#!/usr/bin/perl
use warnings;
use strict;
use Graph;
print "##### using Graph version: ", Graph -> VERSION, " #####\n";
my $g = Graph::Undirected -> new(unionfind => 1);
$g -> add_weighted_edge('16977', '14903', 1);
$g -> add_weighted_edge('21062', '4504', 1);
$g -> add_weighted_edge('14671', '10554', 1);
$g -> add_weighted_edge('14903', '8891', 1);
$g -> add_weighted_edge('9714', '14671', 1);
$g -> add_weighted_edge('4504', '13544', 1);
$g -> add_weighted_edge('9714', '13544', 1);
$g -> add_weighted_edge('16977', '8891', 1);
$g -> add_weighted_edge('21062', '21062', 1);
$g -> add_weighted_edge('9714', '4504', 1);
$g -> add_weighted_edge('14671', '21687', 1);
$g -> add_weighted_edge('14671', '16977', 1);
$g -> add_weighted_edge('4504', '21687', 1);
$g -> add_weighted_edge('10554', '14903', 1);
$g -> add_weighted_edge('9714', '21687', 1);
$g -> add_weighted_edge('13544', '14671', 1);
$g -> add_weighted_edge('21062', '14671', 1);
$g -> add_weighted_edge('10554', '8891', 1);
$g -> add_weighted_edge('14671', '14903', 1);
$g -> add_weighted_edge('14671', '14671', 1);
$g -> add_weighted_edge('13544', '13544', 1);
$g -> add_weighted_edge('14671', '14026', 1);
$g -> add_weighted_edge('4504', '14671', 1);
$g -> add_weighted_edge('14671', '8891', 1);
$g -> add_weighted_edge('13544', '14026', 1);
$g -> add_weighted_edge('10554', '16977', 1);
if($g -> is_connected) {
print "The graph is connected\n";
} else {
print "The graph is not connected\n";
}
my $number = scalar($g -> vertices);
print "The number of vertices before SPT_Bellman_Ford: $number\n";
my $spt = $g -> SPT_Bellman_Ford;
$number = scalar($spt -> vertices);
print "The number of vertices after SPT_Bellman_Ford: $number\n";