-
Notifications
You must be signed in to change notification settings - Fork 19
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
__eq__
(equality) can return false for two identical graphs if an edge was added and removed in one of them
#40
Comments
A great catch @Sappique. I'm far away from my PC until the 12th of March, so depending on how urgent this issue is to you I see three options: A) If you are confident to make a pull request, then you can propose a patch and @04t02 and I can review it. Which do you prefer? |
Sorry for the late replay @root-11. If someone does fix it I will be grateful, but I am currently able to use a workaround. |
New release pending workflow completion... |
Release 2023.6.7 available on pypi as: https://pypi.org/project/graph-theory/2023.7.6/ |
If one graph had a edge added and then removed again, comparing it to an identical graph can return false. This occurs it the added and removed edge is outgoing from an node that had no outgoing edges before.
To reproduce
Cause
As far as I can tell, this bug occurs, because
__eq__
compares the two graphs private edge variables_edges
instead of calling the public edge getteredges()
.When an edge from an node, that did not have any outgoing edges before, is added and removed, that edges name remains as a key in the graph's internal edge variable
_edges
. Two dictionaries are unequal if one has a key the other has not, even if all values are equal, thus the two graphs are unequal.Other examples
Because
copy()
uses the public edge getteredges()
this bug can lead to some very confusing behavior:Additional information
I'm using version 2023.7.5 of graph-theory with Python 3.10 on windows.
The text was updated successfully, but these errors were encountered: