X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=mtp_graph.cc;h=ecbbab5a0b1128406828c63743e18366c5e34784;hb=bfbef5a16cf4282429c9f913b6122ffc550790bd;hp=052de17884763a1a32747e149b0f047e3ee23f20;hpb=e03634d09a9049c7ae4fb426c67ad513cc84185a;p=mtp.git diff --git a/mtp_graph.cc b/mtp_graph.cc index 052de17..ecbbab5 100644 --- a/mtp_graph.cc +++ b/mtp_graph.cc @@ -24,9 +24,8 @@ #include "mtp_graph.h" -#include +// #include #include -#include using namespace std; @@ -190,15 +189,25 @@ void MTPGraph::force_positivized_lengths() { scalar_t residual_error = 0.0; scalar_t max_error = 0.0; #endif - for(int n = 0; n < _nb_vertices; n++) { - for(Edge *e = _vertices[n].leaving_edges; e; e = e->next_leaving_edge) { - if(e->positivized_length < 0) { + for(int k = 0; k < _nb_edges; k++) { + Edge *e = _edges + k; + + if(e->positivized_length < 0) { + #ifdef VERBOSE + 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; } +#endif + e->positivized_length = 0.0; } } #ifdef VERBOSE