You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some cases the private _edges of a graph can gain an empty dict as a entry. This leads to incorrect behavior when comparing graphs.
This bug is very similar to #40.
The equality function of graphs compares the private variable _edges of both graphs and if they are not equal, the function returns false.
The variable _edges can in some cases be accessed with keys that don't exist, since it is a defaultdict(dict) in those cases a empty dict is created for that key. If that happens with only one of two identical graphs, they are no longer equal.
The accessing of _edges with not existing keys and thus the creation of a new entry can occur when edge(node1, node2) is called with a node1 without outgoing edges or sometimes when is_connected(n1, n2) is called depending on the graph. Those are the two examples I found, there could be more.
Other problems
Just like with #40 this also causes strange behavior when copying graphs, because copy() uses the public edge getter edges() instead of the private variable _edges.
In some cases the private
_edges
of a graph can gain an empty dict as a entry. This leads to incorrect behavior when comparing graphs.This bug is very similar to #40.
To reproduce
Cause
The equality function of graphs compares the private variable
_edges
of both graphs and if they are not equal, the function returns false.The variable
_edges
can in some cases be accessed with keys that don't exist, since it is adefaultdict(dict)
in those cases a emptydict
is created for that key. If that happens with only one of two identical graphs, they are no longer equal.The accessing of
_edges
with not existing keys and thus the creation of a new entry can occur whenedge(node1, node2)
is called with anode1
without outgoing edges or sometimes whenis_connected(n1, n2)
is called depending on the graph. Those are the two examples I found, there could be more.Other problems
Just like with #40 this also causes strange behavior when copying graphs, because
copy()
uses the public edge getteredges()
instead of the private variable_edges
.Additional information
I'm using version 2023.7.6 of graph-theory with Python 3.10 on windows.
The text was updated successfully, but these errors were encountered: