blokhead,
Of course, you can probably guess that I prefer the elegance of using the high-level abstraction of graph theory ;)

Yes, I know how much you like theory and abstractions, but I also know how slow they can be.

As for efficiency of the compare() sub.. I doubt mine is insanely slow. At worst, the calls to $g->has_edge would cost a few hash lookups in the internals of Graph. If optimization really is a concern at such a low level...

From the original post, I had focused on "I need to implement a fast compare..." and, more importantly, "I need to do millions of comparisons..." With function calls being notriously slow in perl, adding 1 or 2 more to compare() is bound to be slower not faster which is what I believe the OP is after.

I follow everything you write very closely and in private conversations I have expressed my interest in you writing a tutorial to graph theory as a means to problem solving. I think your abstraction could still be very useful as a means for making the code more elegant provided there is a straight forward way to convert the resulting graph back into the HoH (for fast lookups).

Cheers - L~R


In reply to Re^4: Partial Order by Limbic~Region
in thread Partial Order by b4swine

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.