From: Tara L Andrews Date: Fri, 26 Oct 2012 12:23:06 +0000 (+0200) Subject: all_related except for repetition X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f9b9b580808fe9dd15b84c0e242962ad9cbb5179;p=scpubgit%2Fstemmatology.git all_related except for repetition --- diff --git a/analysis/lib/Text/Tradition/Analysis.pm b/analysis/lib/Text/Tradition/Analysis.pm index 45810b5..fa29876 100644 --- a/analysis/lib/Text/Tradition/Analysis.pm +++ b/analysis/lib/Text/Tradition/Analysis.pm @@ -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; }