# The lists of 'in' and 'out' should not have any element that appears
# in 'proposed_related'.
foreach my $pr ( @proposed_related ) {
- foreach my $e ( $pr->incoming ) {
+ foreach my $e ( grep { $_->sub_class eq 'path' } $pr->incoming ) {
if( exists $pr_ids{ $e->from->name } ) {
return 0;
}
}
- foreach my $e ( $pr->outgoing ) {
+ foreach my $e ( grep { $_->sub_class eq 'path' } $pr->outgoing ) {
if( exists $pr_ids{ $e->to->name } ) {
return 0;
}
# Returns all readings related to the one we've got.
sub related_readings {
- my( $self, $colocated ) = @_;
+ my( $self, $colocated, $queried ) = @_;
+ $queried = { $self->name => 1 } unless $queried;
my @related;
+ # Get the nodes directly related to this one
foreach my $e ( $self->edges ) {
next unless $e->isa( 'Text::Tradition::Collation::Relationship' );
next if $colocated && $e->type eq 'repetition';
- push( @related, $e->from eq $self ? $e->to : $e->from );
+ my $n = $e->from eq $self ? $e->to : $e->from;
+ next if $queried->{$n->name};
+ push( @related, $n );
}
+ # Now query those nodes for their relations, recursively
+ map { $queried->{$_->name} = 1 } @related;
+ my @also_related;
+ foreach ( @related ) {
+ push( @also_related, $_->related_readings( $colocated, $queried ) );
+ }
+ push( @related, @also_related );
return @related;
}
eval { no warnings; binmode $DB::OUT, ":utf8"; };
my( $informat, $inbase, $outformat, $help, $linear, $name, $HACK )
- = ( '', '', '', '', 0, 0 );
+ = ( '', '', '', '', 1, 'Tradition', 0 );
GetOptions( 'i|in=s' => \$informat,
'b|base=s' => \$inbase,