节点 #0 没有 'label' 属性?怎么会发生

Sha*_*Pei 1 python networkx

我是 python 和网络的新用户,我无法从 .gml 文件中读取一些数据我的 IDE 是 Spyder,Anaconda,操作系统是 macOS 我是按照在线说明操作的,这是我的代码,这是数据集

import networkx as nx
import matplotlib.pyplot as plt 

G = nx.Graph()
G = nx.read_gml('karate.gml')

print (nx.info(G))
Run Code Online (Sandbox Code Playgroud)

然后编译器显示“节点#0 没有‘标签’属性”。怎么会发生

小智 5

If you are using that popular karate.gml datasets, try the code below:

G = nx.read_gml('karate.gml', label = 'id')
Run Code Online (Sandbox Code Playgroud)