From 48151b87e5f4212f9693d05129c52295b3c11ced Mon Sep 17 00:00:00 2001
From: Romain BERNARD <30secondstodraw@gmail.com>
Date: Tue, 19 Mar 2024 18:16:31 +0100
Subject: [PATCH] change method implementation to get the single best solution

---
 src/ShortestPath/Transit/TransitStateContainer.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/ShortestPath/Transit/TransitStateContainer.h b/src/ShortestPath/Transit/TransitStateContainer.h
index 12e92ca..fbb3ea4 100644
--- a/src/ShortestPath/Transit/TransitStateContainer.h
+++ b/src/ShortestPath/Transit/TransitStateContainer.h
@@ -43,7 +43,13 @@ public:
      * @param nodeIndex
      * @return The first solution of potentially two saved in this array
      */
-    std::vector<TransitAlgorithmState>& getBestSolutions(int nodeIndex){ return solutionVector.at(nodeIndex);}
+    [[nodiscard]] const TransitAlgorithmState& getBestSolution(int nodeIndex) const{
+        if(solutionVector.at(1) < solutionVector.at(0))
+            return solutionVector.at(nodeIndex).at(1);
+        else
+            return solutionVector.at(nodeIndex).at(0);
+    }
+
     TransitAlgorithmState& getBestSolution(int nodeIndex, int nbConnections){ return solutionVector.at(nodeIndex).at(nbConnections == 0 ? 0 : nbConnections - 1);}
     std::vector<TransitAlgorithmState>& getSolutions(int nodeIndex){ return solutionVector.at(nodeIndex);}
     std::vector<std::vector<TransitAlgorithmState>>& getSolutionsVector(){ return solutionVector;}
-- 
GitLab