KML-PolyMap
view release on metacpan or search on metacpan
lib/Geo/KML/PolyMap.pm view on Meta::CPAN
#Assign points to clusters
my $assn = assign_clusters($data,$rcenters);
for (;$npass>0;$npass--) {
#Recalculate centroids
$rcenters = recalculate_centroids($data,$rcenters,$assn);
#Assign points to clusters
my $newassn = assign_clusters($data,$rcenters);
# End the iterations if the assignments don't change
my $done = 1;
for (my $i = 0;$i<scalar(@$newassn) and $done; $i++) {
$done = ($assn->[$i] == $newassn->[$i])
}
if ($done) {
$npass = 0;
} else {
$assn = $newassn;
}
}
( run in 1.128 second using v1.01-cache-2.11-cpan-71847e10f99 )