Venerable Monks,

Please hear me for I am in much need of your wisdom...

Nearing the anniversary of this (Golf) post, I find myself faced with a similar, "bacon number" type problem.

I have a MySQL database of collected factoids (nodes), each identified by a unique integer. Intersecting factoids (vertices) are identified in graph coordinate fashion. So, if fact1id='1' and fact2id='2', the intersection between them is identified as (1,2).

After hours of searching the web, a good deal of thought and much fiddling with code, I am left wondering about a few things... (Please read more for questions.)

Firstly, since the data is not recorded in the database in similar form to the Bacon/Golf post mentioned above, I am wondering if the form

%t =(22 =>[7, 40, 19, 24, 21, 33], ... 40 =>[18, 33, 23, 37, 22, 48, 26, 45], ... 23 =>[25, 46, 27, 40], ... 27 =>[46, 2, 28, 16, 23, 47] ... );

is the best structure for the data. In other words, is there a better choice of data structures? This is the way I have been ordering the data culled from the database, but only because of the example.

Secondly, though I am quite sure the Perl golf examples are well done, I have a hard time following them let alone coaxing out the results I would hope to get. Does anyone have or know where I can find a more fleshed out example of a shortest path/breadth first search (with "bacon number" tracking, perferably) in Perl? The samples I have been looking at are in C or Java--I don't know Java and it's been years and years since I looked at C.

Lastly, and this is the tie-in for all of the above, how would an experienced Perl programmer approach the problem?

Thanks very much in advance for any help!

porkpilot

Edit by tye, adjust links


In reply to Graph traversal--shortest path? by porkpilot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.