Python算例:
【Intro to Graph Optimization with NetworkX in Python - DataCamp】
https://www.datacamp.com/community/tutorials/networkx-python-graph-tutorial#visualizegraph
networkx版本:2.4
【1】g.node[nlrow[‘id‘]] = nlrow[1:].to_dict()
报错 AttributeError: ‘Graph‘ object has no attribute ‘node‘
新版改为:g.nodes[nlrow[‘id‘]].update(nlrow[1:].to_dict())
【2】g.edges(data=True)[0:5]
报错 TypeError: ‘EdgeDataView‘ object is not subscriptable
新版改为:list(g.edges(data=True))[0:5]
同理,g.nodes(data=True)[0:10] 改为:list(g.nodes(data=True))[0:10]
【Python语法-20210720】Graph Optimization with NetworkX in Python
原文:https://www.cnblogs.com/harmanchen/p/15037319.html