Thread Erzeugen von Referenz von Array von Array (eine Frage noch!)
(39 answers)
Opened by kimmy at 2011-09-28 15:57
Ach so...
Kennst du zufällig ein Perl Modul "Algorithm::Cluster"? Ich habe zwei Perl-Skripte gemacht, aber ich bekomme unterschiedliche Ergebeisse. Könntest du mir sagen, wieso ich unterschiedliches Ergebnis bekomme? Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 #!/usr/bin/perl use strict; use warnings; use Algorithm::Cluster; my $data = [ [], [3], [10,10], [10,10,3], [10,10,3,3], [10,10,3,2,3], [10,10,3,3,3,3], [10,10,7,10,7,8,10] ]; print "-------[pairwise average linkage]-------\n"; my %params = ( method => 'a', data => $data ); my ($i,$j,$n); my $tree = Algorithm::Cluster::treecluster(%params); $n = $tree->length; for ($i = 0; $i < $n; $i++) { my $node = $tree->get($i); printf("%3d: %3d %3d %7.3f\n",-1-$i,$node->left,$node->right,$node->distance); } Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 #!/usr/bin/perl use strict; use warnings; use Algorithm::Cluster; use Data::Dumper; my @data_array; while(<>){ chomp; push @data_array, [split(/,/,$_)]; } my $data = \@data_array; print "-------[pairwise average linkage]-------\n"; my %params = ( method => 'a', data => $data ); my ($i,$j,$n); my $tree = Algorithm::Cluster::treecluster(%params); $n = $tree->length; for ($i = 0; $i < $n; $i++) { my $node = $tree->get($i); printf("%3d: %3d %3d %7.3f\n",-1-$i,$node->left,$node->right,$node->distance); } Last edited: 2011-09-28 17:17:50 +0200 (CEST) |