Hello Monks,
ok, here's my problem - I have a list of id's, we'll call it 'list1', each of which is associated with 1 to 3 id's from list2; I need to break up list2 into several sets, where each of the list2 ids in the set has at least one list1 id in common with at least one other list2 id.
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:
use Graph::Undirected;
foreach my $ids (@list1){
$g->add_path(@$ids);
)
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.
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?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.