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
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
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.
Are you posting in the right place? Check out Where do I post X? to know for sure.
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
Want more info? How to link
or How to display code and escape characters
are good places to start.