diff --git a/include/andres/graph/lifting.hxx b/include/andres/graph/lifting.hxx index be057b7..2919c52 100755 --- a/include/andres/graph/lifting.hxx +++ b/include/andres/graph/lifting.hxx @@ -4,7 +4,8 @@ #include #include -#include +#include // std::abs +#include // std::abs since c++17 #include #include // std::iterator_traits #include // std::fill @@ -118,7 +119,7 @@ lift( { const std::size_t offsetX = (metric == LiftingMetric::PathLength) ? distanceUpperBound - offsetY: - ::floor(::sqrt(distanceUpperBoundSquared - offsetY * offsetY)); + std::floor(std::sqrt(distanceUpperBoundSquared - offsetY * offsetY)); const std::size_t col0 = cv[0] < offsetX ? 0 : cv[0] - offsetX; std::size_t colN = cv[0] + offsetX; @@ -129,7 +130,8 @@ lift( { if (metric == LiftingMetric::PathLength) { - const std::size_t distance = std::abs(x - cv[0]) + std::abs(yPlus - 1 - cv[1]); + const std::size_t distance = std::abs(static_cast(x - cv[0])) + + std::abs(static_cast(yPlus - 1 - cv[1])); if (distance > distanceLowerBound) { @@ -189,7 +191,7 @@ lift( { const std::size_t offsetX = (metric == LiftingMetric::PathLength) ? distanceUpperBound - offsetY : - ::floor(::sqrt(distanceUpperBoundSquared - offsetY * offsetY)); + std::floor(std::sqrt(distanceUpperBoundSquared - offsetY * offsetY)); const std::size_t col0 = cv[0] < offsetX ? 0 : cv[0] - offsetX; std::size_t colN = cv[0] + offsetX; diff --git a/src/andres/graph/unit-test/lifting.cxx b/src/andres/graph/unit-test/lifting.cxx index 435e77f..a01a5d4 100755 --- a/src/andres/graph/unit-test/lifting.cxx +++ b/src/andres/graph/unit-test/lifting.cxx @@ -64,6 +64,28 @@ void testLiftGridGraphPathLengthMetric() { andres::graph::Graph<> graphLifted; andres::graph::lift(graph, graphLifted, distanceUpperBound, distanceLowerBound); // tested by function testLiftGraph + /* + std::cout << "lb=" << distanceLowerBound + << ", up=" << distanceUpperBound + << std::endl; + for(size_t v = 0; v < gridGraph.numberOfVertices(); ++v) { + andres::graph::GridGraph<2>::VertexCoordinate vc; + gridGraph.vertex(v, vc); + std::cout << "neighbors of node " + << "(" << vc[0] << ", " << vc[1] << ")" << std::endl; + for(auto it = graphLifted.verticesFromVertexBegin(v); it != graphLifted.verticesFromVertexEnd(v); ++it) { + gridGraph.vertex(*it, vc); + std::cout << "(" << vc[0] << ", " << vc[1] << ") "; + } + std::cout << std::endl; + for(auto it = gridGraphLifted.verticesFromVertexBegin(v); it != gridGraphLifted.verticesFromVertexEnd(v); ++it) { + gridGraph.vertex(*it, vc); + std::cout << "(" << vc[0] << ", " << vc[1] << ") "; + } + std::cout << std::endl; + } + */ + test(gridGraphLifted.numberOfVertices() == gridGraph.numberOfVertices()); test(gridGraphLifted.numberOfEdges() == graphLifted.numberOfEdges()); for(size_type v = 0; v < graphLifted.numberOfVertices(); ++v)