diff --git a/routing/base/astar_algorithm.hpp b/routing/base/astar_algorithm.hpp index 5305021fa7..3bda762d7d 100644 --- a/routing/base/astar_algorithm.hpp +++ b/routing/base/astar_algorithm.hpp @@ -356,6 +356,23 @@ void AStarAlgorithm::ReconstructPath(TVertexType const & v, map const & parent, vector & path) { +#ifdef DEBUG + { + // Do not add the dependency from std/set.hpp. + map visited; + TVertexType cur = v; + while (true) + { + CHECK_EQ(visited.find(cur), visited.end(), ("Parent links form a cycle.")); + visited[cur] = true; + auto it = parent.find(cur); + if (it == parent.end()) + break; + cur = it->second; + } + } +#endif + path.clear(); TVertexType cur = v; while (true)