Я пытаюсь поработать с пакетом networkx в python и застрял на самом базовом уровне. Я даже не могу заставить самые простые фрагменты кода работать в моей среде.
Например:
import networkx as nx
G = nx.Graph()
G.add_node(1)
G.add_nodes_from([2, 3])
G.add_nodes_from(range(4, 7))
G.add_edge(1, 2)
G.add_edge(1, 1)
G.add_edges_from([(2,3), (3,6), (4,6), (5,6)])
list(G.nodes)
Выдает следующую ошибку:
> --------------------------------------------------------------------------- TypeError Traceback (most recent call
> last) <ipython-input-280-90765acb4d1b> in <module>()
> 9 G.add_edges_from([(2,3), (3,6), (4,6), (5,6)])
> 10
> ---> 11 list(G.nodes)
>
> ~\Anaconda3\envs\tracx\lib\site-packages\networkx\classes\graph.py in
> nodes(self)
> 717
> 718 """
> --> 719 nodes = NodeView(self)
> 720 # Lazy View creation: overload the (class) property on the instance
> 721 # Then future G.nodes use the existing View
>
> ~\Anaconda3\envs\tracx\lib\site-packages\networkx\classes\reportviews.py
> in __init__(self, graph)
> 166
> 167 def __init__(self, graph):
> --> 168 self._nodes = graph._node
> 169
> 170 # Mapping methods
>
> TypeError: descriptor '_nodes' for 'NodeView' objects doesn't apply to
> 'NodeView' object
У меня установлено 2.1 и я запускаю его с ноутбука Jupyter с python 3.5.
Что мне здесь не хватает?