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

florentine_families.ipynb example has errors when used with networkx >= 2.4 #21

Open
thisisnic opened this issue Feb 4, 2021 · 0 comments

Comments

@thisisnic
Copy link

thisisnic commented Feb 4, 2021

In networkx >= 2.4, the Graph.node function has been deprecated in favour of Graph.nodes (see https://networkx.org/documentation/stable/release/release_2.4.html#deprecations).

This means that when using versions of networkx greater or equal to 2.4, when running the florentime_families example notebook, the code chunk pasted below results in an error:

for f in G.nodes():
    for i, c in enumerate(communities):
        if f in c:
            G.node[f].update({"community" : str(i),
                                "centrality" : centralities[f],
                                "name" : f
                               })

AttributeError: 'Graph' object has no attribute 'node'

It can be fixed by changing the bit that says G.node[f].update to G.nodes[f].update, though I'm not sure if a bigger change involving refactoring the code a little and using G.set_node_attributes() instead might be a better solution that works on all versions.

If it'd be helpful, I could submit a PR with one of the suggested fixes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant