# Otherwise, first make a lookup table of all the
# readings related to either the source or the target.
my @proposed_related = ( $source, $target );
- push( @proposed_related, $self->related_readings( $source, 'colocated' ) );
- push( @proposed_related, $self->related_readings( $target, 'colocated' ) );
+ # Drop the collation links of source and target, unless we want to
+ # add a collation relationship.
+ foreach my $r ( ( $source, $target ) ) {
+ $self->_drop_collations( $r ) unless $rel eq 'collated';
+ push( @proposed_related, $self->related_readings( $r, 'colocated' ) );
+ }
my %pr_ids;
map { $pr_ids{ $_ } = 1 } @proposed_related;
}
}
+sub _drop_collations {
+ my( $self, $reading ) = @_;
+ foreach my $n ( $self->graph->neighbors( $reading ) ) {
+ if( $self->get_relationship( $reading, $n )->type eq 'collated' ) {
+ $self->del_relationship( $reading, $n );
+ }
+ }
+}
+
=head2 related_readings( $reading, $filter )
Returns a list of readings that are connected via relationship links to $reading.