Added the stress test. Ignore disconnected nodes when checking the residual error.
[mtp.git] / mtp_graph.cc
index 2dd145d..ecbbab5 100644 (file)
@@ -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;
     }