Skip Menu |

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

Report information
The Basics
Id: 5926
Status: open
Priority: 0/
Queue: Graph-Layderer

People
Owner: Nobody in particular
Requestors: hossman_cpan [...] fucit.org
Cc:
AdminCc:

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



Subject: Graph::Layouter::Spring ignores weight?
Consider what you should get, given the following... my $g = Graph::Undirected->new(); # evenly weighted triangle 1->2->3->1 $g->add_weighted_edge(1 , 10 , 2); $g->add_weighted_edge(2 , 10 , 3); $g->add_weighted_edge(3 , 10 , 1); # put 4 in the middle, heavily drawn to 1 $g->add_weighted_edge(1 , 200, 4); $g->add_weighted_edge(2 , 20 , 4); $g->add_weighted_edge(3 , 20 , 4); my $img = Imager->new(xsize => 800, ysize => 600, channels => 4); $img->box(color => Imager::Color->new(0xff, 0xff, 0xff), xmin => 0, ymin => 0, xmax => 800, ymax => 600, filled => 1); Graph::Renderer::Imager::render($g, $img); ..that should (in theory) create something similar to an equalateral triangle of points 1, 2 & 3; with point #4 in the middle, closer to 1 then 2 and 3. In practice, it seems like mater what weights are specified for each edge, it always produces something similar to a square, with an X through the middle. It doesn't seem to ever put items with (relatively) higher weights closer together.
Thanks for the report, I will have a look. The attractive force indeed is not very strong, but it should have at least some effect, I think. By the way, could I please use your script as one of the examples in the eg/ directory?
[PASKY - Mon Apr 5 18:31:43 2004]: Show quoted text
> By the way, could I please use your script as one of the examples in > the eg/ directory?
sure. go nuts
#!/usr/bin/perl use strict; use warnings; use diagnostics; use Imager; use Graph::Undirected; use Graph::Layouter::Spring; use Graph::Renderer::Imager; my $g = Graph::Undirected->new(); $g->set_attribute("renderer_vertex_font", '/usr/share/fonts/truetype/Verdana.ttf'); # evenly weighted triangle 1->2->3->1 $g->add_weighted_edge(1 , 1 , 2); $g->add_weighted_edge(2 , 1 , 3); $g->add_weighted_edge(3 , 1 , 1); # put 4 in the middle, equally heavily drawn to 1 $g->add_weighted_edge(1 , 10, 4); $g->add_weighted_edge(2 , 2 , 4); $g->add_weighted_edge(3 , 2 , 4); Graph::Layouter::Spring::layout($g); my $img = Imager->new(xsize => 800, ysize => 600, channels => 4); $img->box(color => Imager::Color->new(0xff, 0xff, 0xff), xmin => 0, ymin => 0, xmax => 800, ymax => 600, filled => 1); Graph::Renderer::Imager::render($g, $img); $img->write(file=>'t.png');