Skip to content Skip to sidebar Skip to footer

Module 'networkx' Has No Attribute 'add_nodes_from'

I have a dictionary with author name strings as indexes and the number of publications as the associated value. When I try adding nodes to a new graph from it, I get the following

Solution 1:

You're calling add_nodes_from the wrong way. It is a method of the base MultiGraph class, and not an attribute of the networkx module itself. So the Syntax should be

G = nx.MultiGraph()
G.add_nodes_from(auth_dict)

(notice the dot instead of '=').

So i guess you're calling it as

G = nx.add_nodes_from(foo)

in your main code, which is, again, the wrong syntax - look here or at the link you posted yourself for more info.

Post a Comment for "Module 'networkx' Has No Attribute 'add_nodes_from'"