equivalence => 'get',
set_equivalence => 'set',
remove_equivalence => 'delete',
+ _clear_equivalence => 'clear',
},
);
eqreadings => 'get',
set_eqreadings => 'set',
remove_eqreadings => 'delete',
+ _clear_eqreadings => 'clear',
},
);
my( $self, $source, $target ) = @_;
my $seq = $self->equivalence( $source );
my $teq = $self->equivalence( $target );
- print STDERR "Adding equivalence edge $seq -> $teq for $source -> $target\n"
- if grep { $_ eq '451,2' } @_;
$self->equivalence_graph->add_edge( $seq, $teq );
}
sub rebuild_equivalence {
my $self = shift;
my $newgraph = Graph->new();
+ # Set this as the new equivalence graph
+ $self->_reset_equivalence( $newgraph );
+ # Clear out the data hashes
+ $self->_clear_equivalence;
+ $self->_clear_eqreadings;
+
+ # Add the readings
foreach my $r ( $self->collation->readings ) {
- $newgraph->add_vertex( $r->id );
+ my $rid = $r->id;
+ $newgraph->add_vertex( $rid );
+ $self->set_equivalence( $rid, $rid );
+ $self->set_eqreadings( $rid, [ $rid ] );
}
+
+ # Now add the edges
foreach my $e ( $self->collation->paths ) {
- $newgraph->add_edge( @$e );
+ $self->add_equivalence_edge( @$e );
}
- # Set this as the new equivalence graph
- $self->_reset_equivalence( $newgraph );
-
- # Now collapse some nodes. This does no testing; it assumes that all
- # preexisting relationships are valid.
+
+ # Now equate the colocated readings. This does no testing;
+ # it assumes that all preexisting relationships are valid.
foreach my $rel ( $self->relationships ) {
my $relobj = $self->get_relationship( $rel );
next unless $relobj && $relobj->colocated;