-
Notifications
You must be signed in to change notification settings - Fork 61
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
Remove networkx<3 version constraint #1442
Comments
The issue is with More importantly, they've gone from a set to a dict in the algorithm and when the root node is not specified, this makes a difference. Setup for test:from indra.statements import *
from indra.assemblers.pysb import PysbAssembler
from indra.assemblers.pysb.export import export_cm_network
from indra.assemblers.pysb.kappa_util import get_cm_cycles
from networkx.algorithms.cycles import cycle_basis
stmts = [Complex([Agent('a'), Agent('b')]),
Complex([Agent('a'), Agent('c')]),
Complex([Agent('b'), Agent('c')])]
pa = PysbAssembler(stmts)
pa.make_model()
graph = export_cm_network(pa.model)
cycles = get_cm_cycles(graph) Set vs dictnodes_set = set(graph.nodes())
nodes_set.pop()
# 0
nodes_set
# {(0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1), 1, 2}
nodes_dict = dict.fromkeys(graph)
nodes_dict.popitem()[0]
# (2, 1)
nodes_dict
# {0: None,
# (0, 0): None,
# (0, 1): None,
# 1: None,
# (1, 0): None,
# (1, 1): None,
# 2: None,
# (2, 0): None} Providing a root nodeIf the root node to look for cycles from is provided, the output can be made consistent between versions: In Networkx 2.8.8 cycle_basis(graph)
# [[(0, 0), (1, 0), 1, (1, 1), (2, 1), 2, (2, 0), (0, 1), 0]]
cycle_basis(graph, 0)
# [[(0, 0), (1, 0), 1, (1, 1), (2, 1), 2, (2, 0), (0, 1), 0]] In Networkx 3.3 cycle_basis(graph)
# [[(1, 1), 1, (1, 0), (0, 0), 0, (0, 1), (2, 0), 2, (2, 1)]]
cycle_basis(graph, 0)
# [[(0, 0), (1, 0), 1, (1, 1), (2, 1), 2, (2, 0), (0, 1), 0]] I will update out |
I could not find any literal text match of |
It would be good to remove the
networkx<=2
constraint but there is at least one test that fails withnetworkx>=3
:It's possible that this is something trivial like the order of nodes in a reported cycle but would have to be investigated.
The text was updated successfully, but these errors were encountered: