#include "routeWalker.h" #include #include #include #include #include #include RouteWalker::RouteWalker() : solutionLength {std::numeric_limits::max()} { } RouteWalker::Solution RouteWalker::findRouteTo(const Link::End & currentEnd, const Node::Ptr & dest) { findRouteTo(currentEnd, dest, 0); return bestSolution; } void // NOLINTNEXTLINE(misc-no-recursion) RouteWalker::findRouteTo(const Link::End & currentEnd, const Node::Ptr & dest, float length) { if (currentEnd.node == dest && length < solutionLength) { bestSolution = currentSolution; solutionLength = length; return; } if (visited.contains(¤tEnd)) { // We've been here before return; } visited.insert(¤tEnd); for (const auto & next : currentEnd.nexts) { const auto link = next.first.lock(); currentSolution.emplace_back(next); findRouteTo(link->ends[!next.second], dest, length + link->length); currentSolution.pop_back(); } visited.erase(¤tEnd); }