Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
andyfengHKU committed Jun 8, 2023
1 parent 0f0c4e2 commit 1569115
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ template<bool TRACK_PATH>
class AllShortestPathState : public BaseBFSState {
public:
AllShortestPathState(uint8_t upperBound, TargetDstNodes* targetDstNodes)
: BaseBFSState{upperBound, targetDstNodes}, maxDistance{0}, numVisitedDstNodes{0} {}
: BaseBFSState{upperBound, targetDstNodes}, minDistance{0}, numVisitedDstNodes{0} {}

inline bool isComplete() final {
return isCurrentFrontierEmpty() || isUpperBoundReached() ||
isAllDstReachedWithMaxDistance();
isAllDstReachedWithMinDistance();
}

inline void resetState() final {
BaseBFSState::resetState();
maxDistance = 0;
minDistance = 0;
numVisitedDstNodes = 0;
visitedNodeToDistance.clear();
}
Expand All @@ -39,7 +39,7 @@ class AllShortestPathState : public BaseBFSState {
}
visitedNodeToDistance.insert({nbrNodeID, currentLevel});
if (targetDstNodes->contains(nbrNodeID)) {
maxDistance = currentLevel;
minDistance = currentLevel;
numVisitedDstNodes += !nbrHasBeenVisited;
}
if constexpr (TRACK_PATH) {
Expand All @@ -50,12 +50,12 @@ class AllShortestPathState : public BaseBFSState {
}

private:
inline bool isAllDstReachedWithMaxDistance() const {
return numVisitedDstNodes == targetDstNodes->getNumNodes() && currentLevel > maxDistance;
inline bool isAllDstReachedWithMinDistance() const {
return numVisitedDstNodes == targetDstNodes->getNumNodes() && currentLevel > minDistance;
}

private:
uint32_t maxDistance;
uint32_t minDistance; // Min distance to add dst nodes that have been reached.
uint64_t numVisitedDstNodes;
frontier::node_id_map_t<uint32_t> visitedNodeToDistance;
};
Expand Down

0 comments on commit 1569115

Please sign in to comment.