I am getting an error:
KeyError: 'long'
when I run this code:
import networkx as nx
graph_input = open("final_graphml_train/myhead.txt", mode='rb')
graph = nx.read_graphml(graph_input)
The file looks like this:
<?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>
I have checked the documentation that allows the "long" format.
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.
How do I avoid the keyerror in networkx?
Upgrade to the newest version of networkx, it is working as of networkx version 2.6.2.
pip install networkx --upgrade