Dear Masters,
Suppose I have the following two variables:
my @X = qw(s1 s2 s3 m1 m2 m3 w1 w2 w3);
and
my @sim = ( # s1 s2 s3 m1 m2 m3 w1 w2 w3 [1.00, 0.92, 0.56, 0.60, 0.45, 0.33, 0.23, 0.23, 0.33], # s1 [0.92, 1.00, 0.50, 0.55, 0.40, 0.33, 0.23, 0.27, 0.36], # s2 [0.56, 0.50, 1.00, 0.60, 0.57, 0.27, 0.20, 0.27, 0.40], # s3 [0.60, 0.55, 0.60, 1.00, 0.82, 0.20, 0.30, 0.40, 0.50], # m1 [0.45, 0.41, 0.57, 0.81, 1.00, 0.19, 0.30, 0.40, 0.50], # m2 [0.33, 0.33, 0.27, 0.20, 0.19, 1.00, 0.25, 0.27, 0.23], # m3 [0.23, 0.23, 0.20, 0.30, 0.30, 0.25, 1.00, 0.75, 0.60], # w1 [0.23, 0.27, 0.27, 0.40, 0.40, 0.27, 0.75, 1.00, 0.80], # w2 [0.33, 0.36, 0.40, 0.50, 0.50, 0.23, 0.60, 0.80, 1.00], # w3 );
As you can see @sim is a pairwise similarity matrix of elements in X. So for example:
sim(s1,s1) = 1 sim(m1,s2) = 0.55
The problem is how can we find a subset of @X, let's call it C(luster), such that the density and the size of that C is maximized? So the size of C can be varied, and we consider every point of X as a centroid.

By maximizing density and size I mean the member of that C should have high similarity among each other AND the member count should be as big as possible, in comparison to other C's. So the output is just 1 best C.

Can anybody suggest a simple algorithm to achieve that in Perl?

---
neversaint and everlastingly indebted.......

In reply to Finding The Best Cluster Problem by neversaint

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.