diff --git a/src/ShortestPath/Transit/TransitAlgorithmState.h b/src/ShortestPath/Transit/TransitAlgorithmState.h index 29ad87aac2b855ac3e36983c3cce386bf93207d0..0bfbd83501cb90a76f3427dab6d44cede7485d06 100644 --- a/src/ShortestPath/Transit/TransitAlgorithmState.h +++ b/src/ShortestPath/Transit/TransitAlgorithmState.h @@ -152,7 +152,8 @@ public: * @return */ [[nodiscard]] bool strictlyDominates(const TransitAlgorithmState& rhs) const { - return this->getInstant() <= rhs.getInstant() && this->getConnections().size() <= rhs.getConnections().size(); + return (this->getInstant() < rhs.getInstant() && this->getConnections().size() <= rhs.getConnections().size()) + || (this->getInstant() == rhs.getInstant() && this->getConnections().size() < rhs.getConnections().size()); } /** diff --git a/src/ShortestPath/Transit/TransitShortestPathPrecompute.cpp b/src/ShortestPath/Transit/TransitShortestPathPrecompute.cpp index 4bcf3323a6e5eb1b9bdd4c0288ee17c7a24171c1..543e70f8f39165ceaabeaa03487e05d0ef98dca6 100644 --- a/src/ShortestPath/Transit/TransitShortestPathPrecompute.cpp +++ b/src/ShortestPath/Transit/TransitShortestPathPrecompute.cpp @@ -63,8 +63,7 @@ TransitStateContainer TransitShortestPathPrecompute::executeAlgorithm(const Grap DEBUG_MSG("Created new state " + newState.toString()); //Add new state to the solution container and the priority queue if it's not strictly dominated by an existing solution - if(!solutionsContainer.strictlyDominates(currentState)) { - DEBUG_MSG("Candidate state " + newState.toString() + " is being added to solution container and priority queue"); + if(newState.getNodeIndex() != -1 && !solutionsContainer.strictlyDominates(newState)) { DEBUG_MSG("Candidate state " + newState.toString() + " is being added to solution container and priority queue\n"); solutionsContainer.addNewState(nextNode, newState); statePriorityQueue.emplace(newState);