将 python 的 networkx 库生成的这段代码作为有效的 GEXF 文件提供,我在文档中找不到将 xmlns:ns0 更改为 xmlns:viz... GEXF 兼容命名空间的任何地方。
<?xml version="1.0" encoding="utf-8"?><gexf xmlns:ns0="http://www.gexf.net/1.1draft/viz"
version="1.1" xmlns="http://www.gexf.net/1.1draft" xmlns:viz="http://www.gexf.net/1.1draft/viz"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/XMLSchema-instance">
<graph defaultedgetype="directed" mode="static">
<attributes class="node" mode="static">
<attribute id="0" title="origin" type="double" />
<attribute id="1" title="size" type="integer" />
</attributes>
<nodes>
<node id="0" label="Vijana Amani Pamoja (VAP)">
<ns0:color b="70" g="11" r="160" />
<ns0:size value="10" />
<attvalues>
<attvalue for="0" value="1.25" />
<attvalue for="1" value="10" />
</attvalues>
</node>
在某个地方,我可能已经覆盖了 networkx 的 write_gexf 函数的默认命名空间的 VIZ 部分,但我也不知道我在哪里做的 - 所以我在这里问。
networkx.write_gexf(G,f) # G is the graph and f is the file to write.
(已编辑):节点说 ns0:... 而不是 viz:... 如 GEXF 文档中所示。这会导致与使用 viz 参数的其他 GEXF 库的兼容性问题(并且找不到它们)。