rkistner / chinese-postman

Python application to solve the Chinese postman problem
MIT License
55 stars 15 forks source link

AttributeError: module 'networkx' has no attribute 'connected_component_subgraphs' #21

Closed itsmi closed 5 years ago

itsmi commented 5 years ago

chineste-postman still uses the 'connected_component_subgraphs' feature of 'networkx', which has been deprecated in networkx version 2.1.

The resulting error message is: AttributeError: module 'networkx' has no attribute 'connected_component_subgraphs'

Is there any fix to this issue? Thanks!

rkistner commented 5 years ago

Seems like it's still present up till 2.3, and removed in 2.4.

Deprecation notice says this is the replacement:

G.subgraph(c) for c in connected_components(G)

Until this is fixed, just stick to networkx 2.3 or earlier.

bradleysawler commented 4 years ago

Found a solution which works:

> def connected_component_subgraphs(G):
    for c in nx.connected_components(G):
        yield G.subgraph(c)
rkistner commented 4 years ago

This has already been fixed in the master branch.

ademidun commented 4 years ago

This is also an issue in mordred for some reason. Any ideas?

module 'networkx' has no attribute 'biconnected_component_subgraphs' (SpAbs_Dt/SpAbs/mordred._matrix_attributes.Eigen(mordred.DetourMatrix.DetourMatrixCache())/mordred.DetourMatrix.DetourMatrixCache())

FanwangM commented 4 years ago

This is also an issue in mordred for some reason. Any ideas?

module 'networkx' has no attribute 'biconnected_component_subgraphs' (SpAbs_Dt/SpAbs/mordred._matrix_attributes.Eigen(mordred.DetourMatrix.DetourMatrixCache())/mordred.DetourMatrix.DetourMatrixCache())

It seems that they are working on that, https://github.com/mordred-descriptor/mordred/issues/84. So you can just basically stick to networkx with version 2.3 in your virtual environment,

pip install --force-reinstall networkx==2.3

This will fix your problem of using mordred.

adityasbg commented 4 years ago

Found a solution which works:

> def connected_component_subgraphs(G):
    for c in nx.connected_components(G):
        yield G.subgraph(c)

Thank you it works

michael-ts commented 1 year ago

def connected_component_subgraphs(G): for c in nx.connected_components(G): yield G.subgraph(c)

This did not work for me; I get the same error as before. Am I supposed to just run it in the Python console first?

michael-ts commented 1 year ago

Ok even more mind boggling, after shaving the yak for a while here trying to get this to work is that I found that the only networkx on the system is this one:

networkx-1.7-py2.7.egg

This is surely version 1.7 which is < 2.4 and thus should not be a problem, right? I'm about to figure out how to tear the egg apart, manually editing the file as needed, and reassemble it. This is ridiculous.