-
Notifications
You must be signed in to change notification settings - Fork 4
Generalize weight used in dijkstra algorithm #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
caf57ea to
f37d1ea
Compare
|
Please @sbaldu remember to update the project version |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #174 +/- ##
=======================================
Coverage 94.47% 94.48%
=======================================
Files 17 18 +1
Lines 2897 2900 +3
Branches 281 281
=======================================
+ Hits 2737 2740 +3
Misses 160 160
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cppcheck (reported by Codacy) found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
src/dsm/headers/DijkstraWeights.cpp
Outdated
| double streetTime(const Graph* graph, Id node1, Id node2) { | ||
| const auto street{graph->street(node1, node2)}; | ||
| const auto length{(*street)->length()}; | ||
| const auto speed{(*street)->maxSpeed() * |
Check warning
Code scanning / Cppcheck (reported by Codacy)
Local variable 'speed' shadows outer function Warning
| addStreets(std::forward<Tn>(streets)...); | ||
| } | ||
|
|
||
| template <typename Func> |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note
| } | ||
|
|
||
| template <typename Func> | ||
| requires(std::is_same_v<std::invoke_result_t<Func, const Graph*, Id, Id>, double>) |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note
| std::optional<DijkstraResult> Graph::shortestPath(const Node& source, | ||
| const Node& destination, | ||
| Func f) const { | ||
| return this->shortestPath(source.id(), destination.id()); |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 15.5 rule Note
| return this->shortestPath(source.id(), destination.id()); | ||
| } | ||
|
|
||
| template <typename Func> |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note
| while (unvisitedNodes.size() != 0) { | ||
| source = *std::min_element(unvisitedNodes.begin(), | ||
| unvisitedNodes.end(), | ||
| [&dist](const auto& a, const auto& b) -> bool { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note
| source = *std::min_element(unvisitedNodes.begin(), | ||
| unvisitedNodes.end(), | ||
| [&dist](const auto& a, const auto& b) -> bool { | ||
| return dist[a].second < dist[b].second; |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 15.5 rule Note
| } | ||
| double streetWeight = getStreetWeight(this, source, neighbour.first); | ||
| // if current path is shorter than the previous one, update the distance | ||
| if (streetWeight + dist[source].second < dist[neighbour.first].second) { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.1 rule Note
| while (true) { | ||
| previous = prev[previous].first; | ||
| if (previous == std::numeric_limits<Id>::max()) { | ||
| return std::nullopt; |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 15.5 rule Note
| } | ||
|
|
||
| std::reverse(path.begin(), path.end()); | ||
| return DijkstraResult(path, prev[destination].second); |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 15.5 rule Note
No description provided.