Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 9c479323d8b3e2e36a382e6c784471db > files > 16

perl-Algorithm-Cluster-1.38-1mdv2008.1.x86_64.rpm

#!/usr/bin/perl 

use Algorithm::Cluster;

$|++;

$^W = 1;
use strict;

my $weight =  [ 1,1 ];

my $data =  [

	[ 1.1, 1.2 ],
	[ 1.4, 1.3 ],
	[ 1.1, 1.5 ],
	[ 2.0, 1.5 ],
	[ 1.7, 1.9 ],
	[ 1.7, 1.9 ],
	[ 5.7, 5.9 ],
	[ 5.7, 5.9 ],
	[ 3.1, 3.3 ],
	[ 5.4, 5.3 ],
	[ 5.1, 5.5 ],
	[ 5.0, 5.5 ],
	[ 5.1, 5.2 ],
];

my $mask =  [

	[ 1, 1 ],
	[ 1, 1 ],
	[ 1, 1 ],
	[ 1, 1 ],
	[ 1, 1 ],
	[ 1, 1 ],
	[ 1, 1 ],
	[ 1, 1 ],
	[ 1, 1 ],
	[ 1, 1 ],
	[ 1, 1 ],
	[ 1, 1 ],
	[ 1, 1 ],
];

print "--------------[pairwise average linkage]-------\n";

my %params = (

	transpose  =>         0,
	method     =>       'a',
	dist       =>       'e',
	data       =>     $data,
	mask       =>     $mask,
	weight     =>   $weight,
);

my $result;
my ($i,$j);

my $result = Algorithm::Cluster::treecluster(%params);

$i=0;
foreach(@{$result}) {
	printf("%3d: %3d %3d %7.3f\n",-1-$i,$_->[0],$_->[1],$_->[2]);
	++$i;
}

print "--------------[pairwise single linkage]-------\n";
$params{method} = 's';

$result = Algorithm::Cluster::treecluster(%params);

$i=0;
foreach(@{$result}) {
	printf("%3d: %3d %3d %7.3f\n",-1-$i,$_->[0],$_->[1],$_->[2]);
	++$i;
}

print "--------------[pairwise centroid linkage]-------\n";
$params{method} = 'c';

$result = Algorithm::Cluster::treecluster(%params);

$i=0;
foreach(@{$result}) {
	printf("%3d: %3d %3d %7.3f\n",-1-$i,$_->[0],$_->[1],$_->[2]);
	++$i;
}

print "--------------[pairwise maximum linkage]-------\n";
$params{method} = 'm';

$result = Algorithm::Cluster::treecluster(%params);

$i=0;
foreach(@{$result}) {
	printf("%3d: %3d %3d %7.3f\n",-1-$i,$_->[0],$_->[1],$_->[2]);
	++$i;
}


__END__