由于 "long" 格式导致的 networkx keyerror

networkx keyerror due to "long" format

我收到一个错误:

按键错误:'long'

当我运行这个代码时:

import networkx as nx
graph_input = open("final_graphml_train/myhead.txt", mode='rb')
graph = nx.read_graphml(graph_input)

文件如下所示:

<?xml version='1.0' encoding='utf-8'?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
  <key id="d20" for="edge" attr.name="key" attr.type="long" />
</graphml>

我已经查看了允许“长”格式的文档。

http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd

key.type.type is a restriction of xs:NMTOKEN Allowed values: boolean, int, long, float, double, string.

如何避免 networkx 中的键盘错误?

升级到最新版本的 networkx,从 networkx 版本 2.6.2 开始工作。

pip install networkx --upgrade