Algorithm-ClusterPoints

 view release on metacpan or  search on metacpan

t/david.t  view on Meta::CPAN

          0.162437565532525, 0.263201431501184, 0.129978315921374,
          0.793832494841805, 0.178997820438735, 0.0218077272294543,
          0.905168559060808, 0.891924348052552, 0.938081568521067,
          0.254338737785897, 0.996268354169768, 0.737522862942225,
          0.707402435927701, 0.547975652500806, 0.613754991224805,
          0.548892694953732, 0.93629937031427, 0.326442937610491,
          0.480429571852749, 0.464996382301475, 0.532078079137317,
          0.921592084121041, 0.715088769889785, 0.21513107235074,
          0.559020924979006, 0.127224125203352, 0.961130673971791,
          0.749319642528345, 0.817096527903072, 0.00468217311938801,
          0.842125962155915, 0.223987465764534, 0.00740032484203468,
          0.959745225679708, 0.0763856585734111, 0.98745607046612,
          0.441357336015653, 0.360354492232229, 0.832556722113718,
          0.459784945020882, 0.50071838838063, 0.214703489182252,
          0.158276717139795);

my @t = ( 0.669069047666817, 0.246009321367247, 0.669759760913358,
          0.672736139603423, 0.281142079463955, 0.484441321894913,
          0.694459591806456, 0.431622015711731, 0.0083859177655583,
          0.343305435170528, 0.535902828209906, 0.955785672910885,
          0.483028378492115, 0.205144729806086, 0.494054479449822,
          0.509955467586487, 0.00424239229590029, 0.907478251953599,
          0.818463696225955, 0.774827116263033, 0.843063340071232,
          0.265995338354408, 0.438260451825066, 0.526294385606356,
          0.429691642370976, 0.207674245794756, 0.420240602240561,
          0.801557223832312, 0.677086852729296, 0.830231346967601,
          0.533945575198366, 0.993513583521725, 0.944759504890662,
          0.954307142740682, 0.552642938089058, 0.56484118584158,
          0.396666963945101, 0.984795340830836, 0.16911409480624,
          0.323175476172459, 0.757119531369703, 0.147721250884565,
          0.655155361491175, 0.448790021142237, 0.718603053976373,
          0.419075745964854, 0.643698671183664, 0.716185597066023,
          0.505424286765837, 0.712011040444231, 0.66245815737917,
          0.600994219792348, 0.347085259687894, 0.138804534304093,
          0.298008866492204, 0.213604365955611, 0.865292898307921,
          0.413996973840263, 0.119203849225947, 0.250913635634767,
          0.628510148379625, 0.715111178774812, 0.738835880848136,
          0.40761510641827, 0.377954854324052, 0.567357585774126,
          0.642450060373186, 0.938423628875263, 0.678952641614835,
          0.568732858373217, 0.663213538650574, 0.312648313433023,
          0.00155005306969969, 0.0219178133062954, 0.231748625359465,
          0.152517458660647, 0.484294189048221, 0.789380913243583,
          0.779835524909593, 0.896662170958997, 0.885085101555823,
          0.938093575934381, 0.926890951248389, 0.880164925656892,
          0.473007192254038, 0.990263549756385, 0.328128871574357,
          0.772579319513547, 0.865045864377002, 0.846492605671251,
          0.313309628956709, 0.565327264627264, 0.0615956785542195,
          0.697764795586416, 0.694983693861239, 0.549879873750378,
          0.184666262539558, 0.492671527123157, 0.375136294582454,
          0.978128287010442);


my $n = @x;

my $clp = Algorithm::ClusterPoints->new(dimension => 4, ordered => 1, radius => 0.1);
$clp->add_point($x[$_], $y[$_], $z[$_], $t[$_]) for 0..$n-1;

my @bfc = $clp->brute_force_clusters_ix;
my @c = $clp->clusters_ix;

# use Data::Dumper;
# print STDERR Data::Dumper->Dump([\@bfc, \@c], [qw($bfc $c)]);
# print STDERR "distance(4, 15) = ".$clp->distance(4, 15)."\n";

is_deeply(\@c, \@bfc, "simple 4d");
# is_deeply(\@bfc, \@sol, "simple 3d brute force");



( run in 1.019 second using v1.01-cache-2.11-cpan-39bf76dae61 )