Skip Menu |

This queue is for tickets about the Graph CPAN distribution.

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

People
Owner: Nobody in particular
Requestors: bsb [...] sanger.ac.uk
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.61
Fixed in: (no value)



Subject: Errors using objects as nodes
Using blessed hash ref (i.e. objects) as vertices, I encountered an error when calling delete_vertex. delete_vertex calls _edges_at(@_). In _edges_at, line 704, it tries to use the passed vertex as an array reference, which must fail. It only tests for existence of ref($v) instead of distinguishing between ref($v) eq 'ARRAY' and ref($v) eq 'my_class_of_choice'. The same thing happens several times throughout the code, e.g. in the 'stringify' method. The version of Graph is 0.63, perl 5.8.1 on OSX 10.3. Thanks for looking into it, Ben
From: bsb [...] sanger.ac.uk
This patch solved the issue for the 2 methods I tried. Cheers, Ben [guest - Tue May 3 11:04:55 2005]: Show quoted text
> Using blessed hash ref (i.e. objects) as vertices, I encountered an > error when calling delete_vertex. delete_vertex calls > _edges_at(@_). In _edges_at, line 704, it tries to use the passed > vertex as an array reference, which must fail. It only tests for > existence of ref($v) instead of distinguishing between ref($v) eq > 'ARRAY' and ref($v) eq 'my_class_of_choice'. The same thing happens > several times throughout the code, e.g. in the 'stringify' method. > > The version of Graph is 0.63, perl 5.8.1 on OSX 10.3. > > Thanks for looking into it, > > Ben
*** Graph.pm Tue May 3 16:10:36 2005 --- /Library/Perl/5.8.1/Graph.pm Tue Apr 12 19:43:45 2005 *************** *** 63,69 **** my $g = shift; my $o = $g->is_undirected; my $e = $o ? "=" : "-"; ! my @e = map { my @v = map { (ref($_) eq 'ARRAY') ? "[" . join(" ", @$_). "]" : $_ } @$_; join($e, $o ? sort @v : @v) } $g->edges05; my @s = sort @e; --- 63,69 ---- my $g = shift; my $o = $g->is_undirected; my $e = $o ? "=" : "-"; ! my @e = map { my @v = map { ref $_ ? "[" . join(" ", @$_). "]" : $_ } @$_; join($e, $o ? sort @v : @v) } $g->edges05; my @s = sort @e; *************** *** 677,683 **** while (my ($i, $v) = each %{ $Vi }) { my %i; @i{ @i } = @i if @i; # @todo: nonuniq hyper vertices? ! for my $u ((ref($v) eq 'ARRAY') ? @$v : $v) { my $j = exists $v{ $u } ? $v{ $u } : ( $v{ $u } = $i ); if (defined $j && exists $i{ $j }) { delete $i{ $j }; --- 677,683 ---- while (my ($i, $v) = each %{ $Vi }) { my %i; @i{ @i } = @i if @i; # @todo: nonuniq hyper vertices? ! for my $u (ref $v ? @$v : $v) { my $j = exists $v{ $u } ? $v{ $u } : ( $v{ $u } = $i ); if (defined $j && exists $i{ $j }) { delete $i{ $j }; *************** *** 699,707 **** my $en = 0; my %ev; for my $v ( ($V->[_f ] & _HYPER) ? $g->vertices_at( @_ ) : @_ ) { ! #use Carp; ! #confess("v: $v, ref=".ref($v)) unless ref($v) eq 'ARRAY'; # Added by bsb ! my $vi = $V->_get_path_id( (ref($v) eq 'ARRAY') ? @$v : $v ); next unless defined $vi; my $Ei = $E->_ids; while (my ($ei, $ev) = each %{ $Ei }) { --- 699,705 ---- my $en = 0; my %ev; for my $v ( ($V->[_f ] & _HYPER) ? $g->vertices_at( @_ ) : @_ ) { ! my $vi = $V->_get_path_id( ref $v ? @$v : $v ); next unless defined $vi; my $Ei = $E->_ids; while (my ($ei, $ev) = each %{ $Ei }) { *************** *** 729,735 **** my $en = 0; my %ev; for my $v ( ($V->[_f ] & _HYPER) ? $g->vertices_at( @_ ) : @_ ) { ! my $vi = $V->_get_path_id( (ref($v) eq 'ARRAY') ? @$v : $v ); next unless defined $vi; my $Ei = $E->_ids; if (wantarray) { --- 727,733 ---- my $en = 0; my %ev; for my $v ( ($V->[_f ] & _HYPER) ? $g->vertices_at( @_ ) : @_ ) { ! my $vi = $V->_get_path_id( ref $v ? @$v : $v ); next unless defined $vi; my $Ei = $E->_ids; if (wantarray) { *************** *** 777,783 **** my $en = 0; my %ev; for my $v ( ($V->[_f ] & _HYPER) ? $g->vertices_at( @_ ) : @_ ) { ! my $vi = $V->_get_path_id( (ref($v) eq 'ARRAY') ? @$v : $v ); next unless defined $vi; my $Ei = $E->_ids; if (wantarray) { --- 775,781 ---- my $en = 0; my %ev; for my $v ( ($V->[_f ] & _HYPER) ? $g->vertices_at( @_ ) : @_ ) { ! my $vi = $V->_get_path_id( ref $v ? @$v : $v ); next unless defined $vi; my $Ei = $E->_ids; if (wantarray) {
Please try Graph 0.64.
Hi, have you tried with newer (0.64 or later) Graph releases?