Skip Menu |

This queue is for tickets about the Graph CPAN distribution.

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

People
Owner: Nobody in particular
Requestors: TELS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 0.80
  • 0.81
Fixed in: (no value)



Subject: add-edge_attributes() on undirected graph wrongly depends on node order
Moin, the attached script shows that depending on the order how the nodes were inserted into an undirected graph, a spurious second edge is created. The expected result is that add_edge_attributes() does not create the second edge in this case. All the best, Tels
Subject: g.pl
#!/usr/bin/perl -w use Graph; use Test::More; plan tests => 4; my $graph = Graph->new( undirected => 1 ); $graph->add_vertex("Berlin"); $graph->add_vertex("Bonn"); $graph->add_edge("Berlin","Bonn"); is ("$graph","Berlin=Bonn"); $graph->set_edge_attributes("Berlin", "Bonn", { color => "red" }); is ("$graph","Berlin=Bonn"); $graph = Graph->new( undirected => 1 ); #$graph->add_vertex("Berlin"); #$graph->add_vertex("Bonn"); $graph->add_edge("Bonn","Berlin"); is ("$graph","Berlin=Bonn"); $graph->set_edge_attributes("Bonn", "Berlin", { color => "red" }); is ("$graph","Berlin=Bonn");
On Sat Jun 30 09:48:45 2007, TELS wrote: Show quoted text
> Moin, > > the attached script shows that depending on the order how the nodes were > inserted into an undirected graph, a spurious second edge is created. > > The expected result is that add_edge_attributes() does not create the > second edge in this case. > > All the best, > > Tels
If I run your test case no spurious second edge gets created?
Subject: Re: [rt.cpan.org #27840] add-edge_attributes() on undirected graph wrongly depends on node order
Date: Thu, 19 Jul 2007 18:16:43 +0200
To: bug-Graph [...] rt.cpan.org
From: Tels <nospam-abuse [...] bloodgate.com>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Moin, On Thursday 19 July 2007 03:11:49 Jarkko_Hietaniemi via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=27840 > > > On Sat Jun 30 09:48:45 2007, TELS wrote:
> > Moin, > > > > the attached script shows that depending on the order how the nodes > > were inserted into an undirected graph, a spurious second edge is > > created. > > > > The expected result is that add_edge_attributes() does not create the > > second edge in this case. > > > > All the best, > > > > Tels
> > If I run your test case no spurious second edge gets created?
Maybe it depends on the hash-insertion/randomness order? Have you uncommented the two commented lines? (Sorry, the version I posted should have uncommented them, but I mangled it). All the best, Tels - -- Signed on Thu Jul 19 18:14:31 2007 with key 0x93B84C15. View my photo gallery: http://bloodgate.com/photos PGP key on http://bloodgate.com/tels.asc or per email. "My name is Felicity Shagwell. Shagwell by name, shag very well by reputation." -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) iQEVAwUBRp+ObHcLPEOTuEwVAQLXZwf+Ju0AnPeZbcWKpQ1A9KSF+5ktOvqrDvfM MvQLbEpxBfa8kEm83EsI2+Xr+EbmOQwtEnGoA1wAGXb25EVxe8HumZ1ocL6qlF5m FCEs7D7ZvGDuMoiR7lripEKiAXC9aS5xxNftIdHr4r0jbAluih7dn3in1/VDQ/0D XeuL4PUoS/VRmJKBfhMg8RxlA8moOXuF0vuKfTUeFOp62XMudufwWHhahMsYMBuv uaDzbO+kp/sJI30ko+qR/V2wHzRxHCr18nErWV6WcZ/8hOhPKGMoqCxezHKrCC+v vinFOgMmpvnOT+L1cqzoSN37y6jwQ2UUUUnPv/jPyXa/lWTk/VfKYA== =TRg8 -----END PGP SIGNATURE-----
Subject: Re: [rt.cpan.org #27840] add-edge_attributes() on undirected graph wrongly depends on node order
Date: Thu, 19 Jul 2007 13:06:52 -0400
To: bug-Graph [...] rt.cpan.org
From: "Jarkko Hietaniemi" <jhi [...] iki.fi>
Show quoted text
> > If I run your test case no spurious second edge gets created?
> > Maybe it depends on the hash-insertion/randomness order?
It's possible. Oh, how I wish the randomized hashes had been the default from very beginning... Show quoted text
> Have you uncommented the two commented lines? (Sorry, the version I posted
Ahhh, no. I'll retry tonight. Show quoted text
> should have uncommented them, but I mangled it). > > All the best, > > Tels > > - -- > Signed on Thu Jul 19 18:14:31 2007 with key 0x93B84C15. > View my photo gallery: http://bloodgate.com/photos > PGP key on http://bloodgate.com/tels.asc or per email. > > "My name is Felicity Shagwell. Shagwell by name, shag very well by > reputation." > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.2 (GNU/Linux) > > iQEVAwUBRp+ObHcLPEOTuEwVAQLXZwf+Ju0AnPeZbcWKpQ1A9KSF+5ktOvqrDvfM > MvQLbEpxBfa8kEm83EsI2+Xr+EbmOQwtEnGoA1wAGXb25EVxe8HumZ1ocL6qlF5m > FCEs7D7ZvGDuMoiR7lripEKiAXC9aS5xxNftIdHr4r0jbAluih7dn3in1/VDQ/0D > XeuL4PUoS/VRmJKBfhMg8RxlA8moOXuF0vuKfTUeFOp62XMudufwWHhahMsYMBuv > uaDzbO+kp/sJI30ko+qR/V2wHzRxHCr18nErWV6WcZ/8hOhPKGMoqCxezHKrCC+v > vinFOgMmpvnOT+L1cqzoSN37y6jwQ2UUUUnPv/jPyXa/lWTk/VfKYA== > =TRg8 > -----END PGP SIGNATURE----- > >
-- There is this special biologist word we use for 'stable'. It is 'dead'. -- Jack Cohen
Subject: Re: [rt.cpan.org #27840] add-edge_attributes() on undirected graph wrongly depends on node order
Date: Sat, 28 Jul 2007 12:29:25 +0200
To: bug-Graph [...] rt.cpan.org
From: Tels <nospam-abuse [...] bloodgate.com>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, On Thursday 19 July 2007 19:07:07 jhi@iki.fi via RT wrote: Show quoted text
[snip] Show quoted text
> > > If I run your test case no spurious second edge gets created?
> > > > Maybe it depends on the hash-insertion/randomness order?
> > It's possible. Oh, how I wish the randomized hashes had been the > default from very beginning... >
> > Have you uncommented the two commented lines? (Sorry, the version I > > posted
> > Ahhh, no. I'll retry tonight.
Have you had a chance to look into this? I encountered the same (a similiar?) bug with multi-edged undirected graphs. Here adding two edges like so: my $id = $out->add_edge_get_id($from,$to); my $attr = $e->raw_attributes(); $out->set_edge_attributes_by_id($from, $to, $id, $attr); can result in _four_ edges. The only remedy I found was that in case of undirected graphs, to _always_ swap $from and $to so that they are in the same predetermined order (basically sorting the $from and $to objects by some global unique ID) like so: if ($opt->{undirected}) { # swap the arguments to avoid creating a spurious edge ($from,$to) = ($to,$from) if $e->{to}->{id} < $e->{from}->{id}; } my $id = $out->add_edge_get_id($from,$to); my $attr = $e->raw_attributes(); $out->set_edge_attributes_by_id($from, $to, $id, $attr); This means, however, that the input graph: Berlin -- Bonn Berlin -- Bonn might result in: Bonn -- Berlin Bonn -- Berlin e.g. the original sorting order of the nodes on the edges was lost (although one can argue that with a true undirected graph this shouldn't matter). I can send in a testscript that demonstrates the problem with multi-edged graphs, if you want. All the best, Tels - -- Signed on Sat Jul 28 12:24:49 2007 with key 0x93B84C15. Get one of my photo posters: http://bloodgate.com/posters PGP key on http://bloodgate.com/tels.asc or per email. "Q: What do you get when you cross an insomniac, an agnostic, and a dyslexic? A: Someone who stays up all night wondering if there is a Dog." -- Groucho Marx -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) iQEVAwUBRqsahXcLPEOTuEwVAQJWAgf8Db7szTuFQfXS11lwUD5NTTNLcBWYVZ1j Tv/FlIsqhvUBNi/ovQpvVgGHRDdXNsprdaYezae+1NAtPKfkUrzNff15hWl49ch6 RGHMdnwD40NOvMkJI2JeJxtEETkaUvkYSDk/nre0xnKeAtH4pzi1rrLVovbGMk7f PladXT/TV9RYISwpQh+Fl4awEJ8Dwk4f+n1BJYAAFu7gN9OTN+tMCaaD89alPZel 8M0Z9H+WguE3QF0bkDj5c7uQ5g1mBMPGyFYRq24bYCwLnb8bJ1l5Swvy1aEmGhkx ic2bKm7lC2S6dLbSra9XHU/ifFN42tjMbZ98r5hA40nNUIc6OYMEfA== =h576 -----END PGP SIGNATURE-----
Subject: Re: [rt.cpan.org #27840] add-edge_attributes() on undirected graph wrongly depends on node order
Date: Mon, 30 Jul 2007 08:34:40 -0400
To: bug-Graph [...] rt.cpan.org
From: Jarkko Hietaniemi <jhi [...] iki.fi>
No, I haven't had chance yet to look at this more... any test scripts are welcome.
Subject: Re: [rt.cpan.org #27840] add-edge_attributes() on undirected graph wrongly depends on node order
Date: Mon, 13 Aug 2007 18:40:11 +0200
To: bug-Graph [...] rt.cpan.org
From: Tels <nospam-abuse [...] bloodgate.com>
Moin, On Monday 30 July 2007 14:34:58 jhi@iki.fi via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=27840 > > > No, I haven't had chance yet to look at this more... any test scripts > are welcome.
GAH! Talk about bad timing. You released Graph v0.83 (without telling me) and it breaks my Graph-Convert-0.08 which I just released because the last time I checked 0.81 was the latest Graph version. And sure enough, it works with 0.81, but breaks with 0.83. Since it works with 0.81, this means either that your "fix" broke something else, or my workaround only works whent the bug is present. Or something. Uhm. I have to dig out the testscripts and see if I can reproduce the issue with a bit simpler code. All the best, Tels -- Signed on Mon Aug 13 18:37:35 2007 with key 0x93B84C15. Get one of my photo posters: http://bloodgate.com/posters PGP key on http://bloodgate.com/tels.asc or per email. "The UAC is making safer worlds through superior firepower."
Download (untitled)
application/pgp-signature 481b

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #27840] add-edge_attributes() on undirected graph wrongly depends on node order
Date: Mon, 13 Aug 2007 12:50:03 -0400
To: bug-Graph [...] rt.cpan.org
From: "Jarkko Hietaniemi" <jhi [...] iki.fi>
The 0.83 fixed the test case you gave me earlier... On 8/13/07, nospam-abuse@bloodgate.com via RT <bug-Graph@rt.cpan.org> wrote: Show quoted text
> > Queue: Graph > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=27840 > > > Moin, > > On Monday 30 July 2007 14:34:58 jhi@iki.fi via RT wrote:
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=27840 > > > > > No, I haven't had chance yet to look at this more... any test scripts > > are welcome.
> > GAH! Talk about bad timing. You released Graph v0.83 (without telling me) > and it breaks my Graph-Convert-0.08 which I just released because the last > time I checked 0.81 was the latest Graph version. And sure enough, it works > with 0.81, but breaks with 0.83. > > Since it works with 0.81, this means either that your "fix" broke something > else, or my workaround only works whent the bug is present. Or something. > Uhm. I have to dig out the testscripts and see if I can reproduce the issue > with a bit simpler code. > > All the best, > > Tels > > -- > Signed on Mon Aug 13 18:37:35 2007 with key 0x93B84C15. > Get one of my photo posters: http://bloodgate.com/posters > PGP key on http://bloodgate.com/tels.asc or per email. > > "The UAC is making safer worlds through superior firepower." > > > >
-- There is this special biologist word we use for 'stable'. It is 'dead'. -- Jack Cohen
Subject: Re: [rt.cpan.org #27840] add-edge_attributes() on undirected graph wrongly depends on node order
Date: Mon, 13 Aug 2007 19:01:14 +0200
To: bug-Graph [...] rt.cpan.org
From: Tels <nospam-abuse [...] bloodgate.com>
Download (untitled)
application/pgp-signature 481b

Message body not shown because it is not plain text.

Moin, On Monday 13 August 2007 18:50:39 jhi@iki.fi via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=27840 > > > The 0.83 fixed the test case you gave me earlier...
Yes, but my testsuite contained one more test for multi-edged, undirected graphs (the one I was talking about earlier, but forgot to send you). And 0.83 just broke this test (as a side-effect, I guess). Since I didn't know until I saw all the test failures for Graph-Convert today, I couldn't have notified you earlier. And since you didn't have had this testcase yet, you couldn't have seen earlier, either. As I said, just extremely unlucky timing in our releases being nearly simultanous :) Please find attached a testscript that shows the new failure with Graph v0.83 (opposed to v0.81) with multi-edged, undirected graphs: # perl t.pl 1..3 # Graph v0.81 ok 1 - is multiedged ok 2 - only one edge # edge ID is 0 # add attribute for edge Berlin Bonn ok 3 - only one edge # perl t.pl 1..3 # Graph v0.83 ok 1 - is multiedged ok 2 - only one edge # edge ID is 0 # add attribute for edge Berlin Bonn not ok 3 - only one edge # Failed test 'only one edge' # in t.pl at line 25. # got: 'Berlin=Berlin,Berlin=Bonn' # expected: 'Berlin=Bonn' # Looks like you failed 1 test of 3. A spurious edge "$from=$from" is generated upon calling $graph->set_edge_attributes_by_id($from,$to,$attributes); Sorry to find out all these hidden corner cases :-) I gladly file a new bugreport if you want to treat this is a sep. issue :) All the best, Tels -- Signed on Mon Aug 13 18:56:49 2007 with key 0x93B84C15. View my photo gallery: http://bloodgate.com/photos PGP key on http://bloodgate.com/tels.asc or per email. Firefox: What are you trying to tell me, that I can block pop-ups? Morpheus: I'm trying to tell you that when you're ready, you won't have to. -- Skyshadow (508) on 2004-11-30 at /.

Message body is not shown because sender requested not to inline it.

Subject: Re: [rt.cpan.org #27840] add-edge_attributes() on undirected graph wrongly depends on node order
Date: Mon, 13 Aug 2007 13:57:24 -0400
To: bug-Graph [...] rt.cpan.org
From: "Jarkko Hietaniemi" <jhi [...] iki.fi>
Okay, it seems that 0.84 is imminent... On 8/13/07, nospam-abuse@bloodgate.com via RT <bug-Graph@rt.cpan.org> wrote: Show quoted text
> > Queue: Graph > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=27840 > > > Moin, > > On Monday 13 August 2007 18:50:39 jhi@iki.fi via RT wrote:
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=27840 > > > > > The 0.83 fixed the test case you gave me earlier...
> > Yes, but my testsuite contained one more test for multi-edged, undirected > graphs (the one I was talking about earlier, but forgot to send you). And > 0.83 just broke this test (as a side-effect, I guess). > > Since I didn't know until I saw all the test failures for Graph-Convert > today, I couldn't have notified you earlier. And since you didn't have had > this testcase yet, you couldn't have seen earlier, either. As I said, just > extremely unlucky timing in our releases being nearly simultanous :) > > Please find attached a testscript that shows the new failure with Graph > v0.83 (opposed to v0.81) with multi-edged, undirected graphs: > > # perl t.pl > 1..3 > # Graph v0.81 > ok 1 - is multiedged > ok 2 - only one edge > # edge ID is 0 > # add attribute for edge Berlin Bonn > ok 3 - only one edge > > # perl t.pl > 1..3 > # Graph v0.83 > ok 1 - is multiedged > ok 2 - only one edge > # edge ID is 0 > # add attribute for edge Berlin Bonn > not ok 3 - only one edge > # Failed test 'only one edge' > # in t.pl at line 25. > # got: 'Berlin=Berlin,Berlin=Bonn' > # expected: 'Berlin=Bonn' > # Looks like you failed 1 test of 3. > > A spurious edge "$from=$from" is generated upon calling > > $graph->set_edge_attributes_by_id($from,$to,$attributes); > > Sorry to find out all these hidden corner cases :-) I gladly file a new > bugreport if you want to treat this is a sep. issue :) > > All the best, > > Tels > > -- > Signed on Mon Aug 13 18:56:49 2007 with key 0x93B84C15. > View my photo gallery: http://bloodgate.com/photos > PGP key on http://bloodgate.com/tels.asc or per email. > > Firefox: What are you trying to tell me, that I can block pop-ups? > > Morpheus: I'm trying to tell you that when you're ready, you won't have > to. > > -- Skyshadow (508) on 2004-11-30 at /. > > >
-- There is this special biologist word we use for 'stable'. It is 'dead'. -- Jack Cohen
I assume 0.84 fixed this one since Tels has been happy...?