all_related except for repetition
Tara L Andrews [Fri, 26 Oct 2012 12:23:06 +0000 (14:23 +0200)]
analysis/lib/Text/Tradition/Analysis.pm

index 45810b5..fa29876 100644 (file)
@@ -403,9 +403,23 @@ sub group_variants {
 }
 
 sub _all_related {
+       # Except by repetition
        my $rdg = shift;
        my $c = $rdg->collation;
-       my @all = map { $c->reading( $_ ) } $c->relations->graph->all_neighbors( $rdg );
+       my @check = ( $rdg );
+       my %seen;
+       while( @check ) {
+               my @next;
+               foreach my $ck ( @check ) {
+                       $seen{"$ck"} = 1;
+                       push( @next, grep { !$seen{"$_"} } 
+                               $ck->related_readings( sub { $_[0]->type ne 'repetition' } ) );
+               }
+               @check = @next;
+       }
+                       
+               
+       my @all = map { $c->reading( $_ ) } keys %seen;
        return @all;
 }