Skip to content
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

Fix bug in Eulerian path algorithm #314

Merged
merged 4 commits into from
May 29, 2023

Conversation

sbaldu
Copy link
Collaborator

@sbaldu sbaldu commented May 29, 2023

Fix bug in the choice of the first node in the Eulerian path algorithm (issue #312).
Also changed the choice of the next node in an edge, so that the algorithm works correctly for undirected graphs as well.
Also added a test case for undirected graphs.

@sbaldu sbaldu requested review from ZigRazor and nrkramer May 29, 2023 12:40
@github-actions github-actions bot added core something about core test Something about test labels May 29, 2023
@ghost
Copy link

ghost commented May 29, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

template <typename T>
const Node<T> *Edge<T>::getOtherNode(const Node<T> *node) const {
if (this->getNodePair().first == node) {
return this->getNodePair().second;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.5 rule

MISRA 15.5 rule
if (this->getNodePair().first == node) {
return this->getNodePair().second;
} else {
return this->getNodePair().first;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.5 rule

MISRA 15.5 rule
// links
auto firstNodeIt =
std::max_element(nodeSet.begin(), nodeSet.end(), [adj](auto n1, auto n2) {
return adj->at(n1).size() < adj->at(n2).size();

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.5 rule

MISRA 15.5 rule
// The starting node is the only node which has more outgoing than ingoing
// links
auto firstNodeIt =
std::max_element(nodeSet.begin(), nodeSet.end(), [adj](auto n1, auto n2) {

Check warning

Code scanning / Cppcheck (reported by Codacy)

misra violation 806 with no text in the supplied rule-texts-file

misra violation 806 with no text in the supplied rule-texts-file
@ZigRazor ZigRazor linked an issue May 29, 2023 that may be closed by this pull request
@codecov
Copy link

codecov bot commented May 29, 2023

Codecov Report

Merging #314 (95610b4) into master (d218e13) will increase coverage by 0.07%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #314      +/-   ##
==========================================
+ Coverage   97.63%   97.71%   +0.07%     
==========================================
  Files          53       53              
  Lines        7449     7487      +38     
==========================================
+ Hits         7273     7316      +43     
+ Misses        176      171       -5     
Flag Coverage Δ
unittests 97.71% <100.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
include/Edge/UndirectedEdge.hpp 100.00% <ø> (ø)
include/Edge/Edge.hpp 100.00% <100.00%> (ø)
include/Graph/Graph.hpp 96.64% <100.00%> (+<0.01%) ⬆️
test/EulerPathTest.cpp 100.00% <100.00%> (ø)

... and 4 files with indirect coverage changes

@ZigRazor ZigRazor merged commit 5fc8449 into ZigRazor:master May 29, 2023
@sbaldu sbaldu deleted the bugfix_eulerian_path branch June 11, 2023 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core something about core test Something about test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible bug in the method for Eulerian paths
3 participants