Search code examples
perlalgorithmcluster-analysis

How can I implement QT (quality threshold) clustering in Perl?


I am having trouble with a QT clustering implementation that I want to implement in Perl.

Algorithm

The line beginning with "identify set", the third from the end, is the part I can't figure out.

The full paper is available here.


Solution

  • A sub i is a cluster. {A sub 1, A sub 2, ..., A sub |G|} is a cluster of clusters.

    Identify set C in {A sub 1, A sub 2, ..., A sub |G|} with maximum cardinality means finding the largest cluster A sub i.

    In perl, if the cluster of clusters is:

    my @bigun = (
                    [1, 2, 3],
                    [4, 5, 6, 7],
                    [8]
                );
    

    then

    # @C = @{ $bigun[1] };
    
    use List::Util qw/reduce/;
    my @C = @{ reduce { @$a > @$b ? $a : $b } @bigun };