Skip Menu |

This queue is for tickets about the Graph-Layout-Aesthetic CPAN distribution.

Report information
The Basics
Id: 11829
Status: resolved
Priority: 0/
Queue: Graph-Layout-Aesthetic

Owner: Nobody in particular
Requestors: thekestrel [...]

Bug Information
Severity: Wishlist
Broken in: 0.08
Fixed in: (no value)

Subject: from_graph feature request
Download (untitled) / with headers
text/plain 2.2k
Hi Ton, For the Graph that I'm using I have already generated a unique identifier numbered list (like $num in from_graph) as I need to keep track of vertices as they are added and removed. For this reason I can't have from_graph assign what is left in the list a new number. I was wondering if you would consider the following as a inclusion in a future build? I'm not familiar with XS or Classes within perl so I've just removed that part (do you have an example of how to use it), but here is a sample of code to explain what I mean. #!/usr/bin/perl # Example - Paul Matthews 3/9/05 use strict; use warnings; use Graph; use Graph::Layout::Aesthetic::Topology; use Graph::Layout::Aesthetic::Monitor::GnuPlot; use Carp; my $debug = 1; #Next unique vertex number my $id_num = 0; sub Get_ID_Num { return $id_num++; } #Make a graph my $g = Graph->new(); #Make some vertices $g->add_vertex("V1"); $g->set_vertex_attribute("V1", "id", Get_ID_Num()); $g->add_vertex("V2"); $g->set_vertex_attribute("V2", "id", Get_ID_Num()); $g->add_vertex("V3"); $g->set_vertex_attribute("V3", "id", Get_ID_Num()); $g->add_vertex("V4"); $g->set_vertex_attribute("V4", "id", Get_ID_Num()); #Make some edges $g->add_edge("V1", "V2"); $g->add_edge("V2", "V3"); $g->add_edge("V3", "V4"); $g->add_edge("V4", "V1"); sub from_graph { my ($graph, %params) = @_; my $attribute = delete $params{id_attribute}; print "attribute : $attribute\n" if $debug; croak "Unknown parameter ", join(", ", keys %params) if %params; my ($num, $f, $t); # Set up a mapping from vertices to numbers my $nr = 0; foreach my $v ( $graph->vertices ) { print "vertex : $v\n" if $debug; $num->{$v} = $graph->get_vertex_attribute($v, $attribute); } $nr = keys %$num; my $topo = Graph::Layout::Aesthetic::Topology->new_vertices($nr); foreach my $e ( $graph->edges ) { ($f, $t) = @{$e}; print "edge $f ($num->{$f}) - $t ($num->{$t})\n" if $debug; $topo->add_edge($num->{$f}, $num->{$t}); } $topo->finish; return $topo; } my $topology = from_graph($g, id_attribute => "id"); my $aglo = Graph::Layout::Aesthetic->new($topology); my $monitor = Graph::Layout::Aesthetic::Monitor::GnuPlot->new(); while (1) { $aglo->gloss(monitor => $monitor); } Regards Paul
Download (untitled) / with headers
text/plain 574b
Hi Paul, I considered your ticket before bringing out a new version, but I decided not to do it. The problem is that currently from_graph basically can't fail, and with your proposed change, whether it works depends on if the externally provided id's are indeed consecutive without holes starting at 0 (that is fundamental to the underlying topology C structure which is a simple array really). The rather special case you have can also simply enough be done by building the Graph::Aesthetic::Topology object yourself exactly because the identifier mapping is so simple.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to