get rid of undefined-value comparison warning
Tara L Andrews [Sun, 5 Feb 2012 21:40:33 +0000 (22:40 +0100)]
lib/Text/Tradition/Collation.pm

index 746504b..a96a789 100644 (file)
@@ -615,13 +615,18 @@ sub _add_edge_weights {
        # the largest number of witness paths each time.
        my $weighted = {};
        my $curr = $self->start->id;
+       my $ranked = $self->end->has_rank;
        while( $curr ne $self->end->id ) {
+               my $rank = $ranked ? $self->reading( $curr )->rank : 0;
                my @succ = sort { $self->path_witnesses( $curr, $a )
                                                        <=> $self->path_witnesses( $curr, $b ) } 
                        $self->sequence->successors( $curr );
                my $next = pop @succ;
+               my $nextrank = $ranked ? $self->reading( $next )->rank : 0;
                # Try to avoid lacunae in the weighted path.
-               while( $self->reading( $next )->is_lacuna && @succ ) {
+               while( @succ && 
+                          ( $self->reading( $next )->is_lacuna ||
+                                $nextrank - $rank > 1 ) ){
                        $next = pop @succ;
                }
                $weighted->{$curr} = $next;