Is anyone having problems reading GraphML files created by yEd?
Whenever I try to read a file created by yEd into a graph, NetworkX
throws the following exception:
File "myscript.py", line 51, in main
G = nx.read_graphml(argv[1])
File "/home/mjs/.local/lib/python2.6/site-packages/networkx/
readwrite/graphml.py", line 100, in read_graphml
glist=list(reader(fh))
File "/home/mjs/.local/lib/python2.6/site-packages/networkx/
readwrite/graphml.py", line 230, in __call__
(keys,defaults) = self.find_graphml_keys(self.xml)
File "/home/mjs/.local/lib/python2.6/site-packages/networkx/
readwrite/graphml.py", line 338, in find_graphml_keys
"type":self.python_type[k.get("attr.type")],
KeyError: None
This seems to be caused by yEd's yFiles extension. yEd-specific keys
do not have an "attr.type" attribute but rather "yfiles.type". For
example, the following was clipped out of a GraphML file created by
yEd:
<!--Created by yFiles for Java 2.7-->
<key for="graphml" id="d0" yfiles.type="resources"/>
<key
attr.name="custom1" attr.type="string" for="node" id="d1">
<default/>
</key>
<key
attr.name="custom2" attr.type="string" for="node" id="d2">
<default/>
</key>
<key
attr.name="url" attr.type="string" for="node" id="d3"/>
<key
attr.name="description" attr.type="string" for="node" id="d4"/>
<key for="node" id="d5" yfiles.type="nodegraphics"/>
<key
attr.name="Description" attr.type="string" for="graph" id="d6">
<default/>
</key>
<key
attr.name="url" attr.type="string" for="edge" id="d7"/>
<key
attr.name="description" attr.type="string" for="edge" id="d8"/>
<key for="edge" id="d9" yfiles.type="edgegraphics"/>
Thoughts? I appreciate any responses in advance!
Matt