Dont work .add_nodes_from ?

295 views
Skip to first unread message

Энергетика с Александром Школьниковым

unread,
Nov 20, 2021, 5:33:46 PM11/20/21
to networkx-discuss
import networkx as nx

grid_graph_1 = nx.Graph
grid_graph_1.add_nodes_from([1,2])


TypeError: add_nodes_from() missing 1 required positional argument: 'nodes_for_adding'

Dan Schult

unread,
Nov 20, 2021, 6:05:56 PM11/20/21
to networkx...@googlegroups.com
Try `nx.Graph()` instead of `nx.Graph`. 
The parens are needed to construct the graph class object, rather than refer to the class itself.

--
You received this message because you are subscribed to the Google Groups "networkx-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to networkx-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/networkx-discuss/e237cc69-3cfb-4f85-9a50-51bbdf576a9fn%40googlegroups.com.

Энергетика с Александром Школьниковым

unread,
Nov 20, 2021, 6:18:46 PM11/20/21
to networkx-discuss
Thanks, it works now!

воскресенье, 21 ноября 2021 г. в 02:05:56 UTC+3, Dan Schult:
Reply all
Reply to author
Forward
0 new messages