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

avoid could_be_isomorphic on nx 3.2 #586

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions libpysal/graph/_set_ops.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import numpy as np
import pandas

from packaging.version import Version

from ._utils import _resolve_islands


Expand Down Expand Up @@ -189,16 +191,19 @@ def isomorphic(self, right):
can be found to convert one graph into the other graph. Requires networkx.
"""
try:
from networkx.algorithms import isomorphism as iso
import networkx as nx
except ImportError:
raise ImportError("NetworkX is required to check for graph isomorphism")

nxleft = self.to_networkx()
nxright = right.to_networkx()

if not iso.faster_could_be_isomorphic(nxleft, nxright):
if not nx.faster_could_be_isomorphic(nxleft, nxright):
return False
elif not iso.could_be_isomorphic(nxleft, nxright):
elif not nx.could_be_isomorphic(nxleft, nxright):
# https://github.com/networkx/networkx/issues/7038
if Version(nx.__version__) == Version("3.2"):
return nx.is_isomorphic(nxleft, nxright)
return False
else:
return iso.is_isomorphic(nxleft, nxright)
return nx.is_isomorphic(nxleft, nxright)
Loading