X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=mtp_graph.cc;h=ecbbab5a0b1128406828c63743e18366c5e34784;hb=82614b1ab1f227fa87ae6b56fd44b97fce58c6a5;hp=2dd145d31c0ff612159bab431e939b5c7cfb933c;hpb=fa06c8a9f47351526c626703be5c75591a499f76;p=mtp.git diff --git a/mtp_graph.cc b/mtp_graph.cc index 2dd145d..ecbbab5 100644 --- a/mtp_graph.cc +++ b/mtp_graph.cc @@ -191,10 +191,21 @@ void MTPGraph::force_positivized_lengths() { #endif for(int k = 0; k < _nb_edges; k++) { Edge *e = _edges + k; + if(e->positivized_length < 0) { + #ifdef VERBOSE - residual_error -= e->positivized_length; - max_error = max(max_error, - e->positivized_length); + if((e->origin_vertex->last_change < 0 && e->terminal_vertex->last_change >= 0) || + (e->origin_vertex->last_change >= 0 && e->terminal_vertex->last_change < 0)) { + cout << "Inconsistent non-connexity (this should never happen)." << endl; + abort(); + } + if(e->origin_vertex->last_change >= 0 && + e->terminal_vertex->last_change >= 0 && + e->positivized_length < 0) { + residual_error -= e->positivized_length; + max_error = max(max_error, - e->positivized_length); + } #endif e->positivized_length = 0.0; }