glwtta has asked for the wisdom of the Perl Monks concerning the following question:
I figured the simplest way to do this is to build a graph with the list2 id's as vertices and an edge between any two that share a list1 id.
I start out with an array (list1) or arrays (list2) of ids (for now I only care about the relationships, not the actual list1 ids) so, I use this to build the graph:
This doesn't seem to work quite as expected, I would think that if I add a path or three vertices and then add another path of three vertices with one vertix in common, then I would end up with 5 connected vertices. From what I actually get, I seem to have two disconnected sets of vertices.use Graph::Undirected; foreach my $ids (@list1){ $g->add_path(@$ids); )
So, am I not getting how Graph::Undirected works, or am I going about this in a completely incorrect fashion (I supposed it's possible it's both)? Any advice?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using Graph::Undirected
by Zaxo (Archbishop) on Feb 21, 2003 at 05:44 UTC | |
by glwtta (Hermit) on Feb 21, 2003 at 15:59 UTC | |
|
Re: using Graph::Undirected
by tall_man (Parson) on Feb 21, 2003 at 05:33 UTC |