-
Notifications
You must be signed in to change notification settings - Fork 103
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
Edge equality operator is incorrect (#333) #326
Conversation
Codecov Report
@@ Coverage Diff @@
## master #326 +/- ##
=======================================
Coverage 97.25% 97.25%
=======================================
Files 54 54
Lines 7934 7977 +43
=======================================
+ Hits 7716 7758 +42
- Misses 218 219 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
This is weird, I tried to reproduce this error but I haven't been able to do it. I copy pasted your exact code and I get all the 11 edges.
Also, in the picture that you provided the hash indexes of the edges are all different, so I doubt that the error that you get is due to the hash function. |
Ok, there is a BUG, the skipped nodes seems to be "new" to the graph. What compiler you are using? |
As said @sbaldu, but also as we can see in the CI/CD where the tests are executed, your test does not fail. |
I'm using MSVC 14.36.32532 (v143) Could it be that Microsoft has a bug in their |
@nrkramer we can try to add in the CI/CD a workflow that works on windows and try to execute tests. |
@nrkramer I think is time to open a new Issue to track this. |
@nrkramer please resolve conflit so we can merge this PR and open a new Issue. |
@ZigRazor It looks like the MSVC builder has some issues. I'm going sleep since it's super late where I am. Feel free to merge once the other checks have passed. |
Demonstration that unique edges are "skipped" sometimes when adding to an
EdgeSet_T
. Wonder if it's hashing, equality, or user error?Running this on my machine:
Which makes me believe we have a bug, are misunderstanding how
std::unordered_set
works, or I'm doing something silly.Let me know what you guys think! @sbaldu @ZigRazor
Update
After much sleuthing, I've found the error to be innocuously hidden here.
It turns out our edge equality operator was incorrect. This causes the underlying hash bucket implemented by various STL incarnations to incorrectly match nodes that are otherwise proven unique (by our hashing function, but STL implementors sometimes check equality anyway).
(As an aside, maybe we should look at a better hash implementation. The bitwise xor ( ^ ) doesn't work for edges that use the same nodes (cycles) since the operation is mathematically symmetrical) - this can result in performance degradation in highly cyclical graphs. Copying boost::hash_combine seems like a good candidate)