I had a similar problem (with a multi-dimensional set of distances between each pair, but I don't think that makes a difference). My solution was to use a "simulated-annealing" approach. A pseudo-code description would be something like

my @items my @best_layout my $least_error for (0..100) { foreach @items add to layout at random x,y best_error_measure = sum of badness of all inter-item distances my $jiggle_distance = largish while($jiggle_distance > smallish) { randomly pick item try it in four alternate locations (up, down, left, right) if(new_error_measure < best_error_measure) keep the item in its best new location else jiggle_distance *= 0.95 } if(best_error_measure < least_error) { save layout into best_layout least_error = best_error_measure } }

This has the advantage that you can take any consideration into account when measuring the "badness" of a layout, for example are there items you want near the centre. For my data it very rapidly converged on a reasonable solution (the optimal solution would have taken much longer but I just needed something that was "good enough").

For my particular data the standard "cluster analysis" approaches gave poor results, and I wanted a two dimensional display of the results.


In reply to Re: RFC: Conceptual association by hawtin
in thread RFC: Conceptual association by SilasTheMonk

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.