Fixed the duplicates (degeneracy) and another assertion problem in LSVineyard dev
authorDmitriy Morozov <dmitriy@mrzv.org>
Wed, 03 Feb 2010 14:51:38 -0800
branchdev
changeset 195 8a6f3ef2c42d
parent 194 6c2a98fb8990
child 196 5303ce3f1934
Fixed the duplicates (degeneracy) and another assertion problem in LSVineyard
include/topology/lsvineyard.hpp
--- a/include/topology/lsvineyard.hpp	Wed Feb 03 11:20:40 2010 -0800
+++ b/include/topology/lsvineyard.hpp	Wed Feb 03 14:51:38 2010 -0800
@@ -126,7 +126,11 @@
     rLog(rlLSVineyard, "Setting up trajectories");
     CF cf; 
     kinetic_map_.clear();
-    for (VertexIndex cur = vertices_.begin(); cur != vertices_.end(); ++cur)
+    
+    // The reverse order takes advantage of how the kinetic sort arranges its elements 
+    // (inserts before the upper bound) to avoid problems with duplicates; it's unfortunate 
+    // that such dependence is necessary, it would be nice to eventually get rid of it.
+    for (VertexIndex cur = boost::prior(vertices_.end()); cur != boost::prior(vertices_.begin()); --cur)
     {
         VertexValue val0 = veval_(cur->vertex());
         VertexValue val1 = veval(cur->vertex());
@@ -165,7 +169,7 @@
     rLog(rlLSVineyardDebug, "Entered swap");
     VertexIndex ao = kinetic_map_[a], bo = kinetic_map_[b];
     rLog(rlLSVineyardDebug, "Vertices: %d %d compare %d", ao->vertex(), bo->vertex(), vcmp_(ao->vertex(), bo->vertex()));
-    AssertMsg(vcmp_(ao->vertex(), bo->vertex()), "In swap(a,b), a must precede b");
+    AssertMsg(!vcmp_(bo->vertex(), ao->vertex()), "In swap(a,b), a must precede b");
     transpose_vertices(ao);
     // AssertMsg(vcmp_(bo->vertex(), ao->vertex()), "In swap(a,b), b must precede a after the transposition");
 }