Subject: | bug in edges() method? |
Date: | Mon, 13 May 2013 18:33:10 +0000 |
To: | "bug-Graph [...] rt.cpan.org" <bug-Graph [...] rt.cpan.org> |
From: | Brian Sherwood <bsherwood [...] juniper.net> |
The edges() method does not always return all edges.
It seems the order the edges are added to the graph makes a difference.
[sherwood@localhost topo]$ uname -a
Linux localhost.localdomain 2.6.32-279.22.1.el6.x86_64 #1 SMP Wed Feb 6 03:10:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[sherwood@localhost topo]$ perl --version
This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi
[sherwood@localhost topo]$ cat t1
#!/usr/bin/perl
use Graph;
use strict;
use warnings;
my $id;
my $g = Graph->new(undirected => 1, multiedged => 1);
$id = $g->add_edge_get_id("a1","s1");
$id = $g->add_edge_get_id("a2","s2");
$id = $g->add_edge_get_id("a2","a1");
print "The graph is:\n";
print $g;
print "\n=====\n";
foreach my $e ($g->edges) {
print "$e->[0],$e->[1]\n";
}
[sherwood@localhost topo]$ cat t2
#!/usr/bin/perl
use Graph;
use strict;
use warnings;
my $id;
my $g = Graph->new(undirected => 1, multiedged => 1);
$id = $g->add_edge_get_id("a2","a1");
$id = $g->add_edge_get_id("a1","s1");
$id = $g->add_edge_get_id("a2","s2");
print "The graph is:\n";
print $g;
print "\n=====\n";
foreach my $e ($g->edges) {
print "$e->[0],$e->[1]\n";
}
Only difference between the two files is the order the edges are added:
[sherwood@localhost topo]$ diff t1 t2
10a11
Show quoted text
> $id = $g->add_edge_get_id("a2","a1");
13d13
< $id = $g->add_edge_get_id("a2","a1");
[sherwood@localhost topo]$ perl t1
The graph is:
a1=a2,a1=s1,a2=s2
=====
a2,s2
a1,s1
[sherwood@localhost topo]$ perl t2
The graph is:
a1=a2,a1=s1,a2=s2
=====
a1,s1
a2,a1
a2,s2
Thanks
Brian Sherwood
Resident Consultant for Comcast
Automation Programming
Hours: 9am-5pm M-F, Bishops Gate
o +1 856.792.3096
m +1 215.499.3135
bsherwood@juniper.net<mailto:bsherwood@juniper.net>
Comcast-DesRE@juniper.net<mailto:Comcast-DesRE@juniper.net>
www.juniper.net<http://www.juniper.net/>