简体   繁体   English

将NetworkX生成的GraphML数据导入Gephi

[英]Import NetworkX generated GraphML data to Gephi

I am trying to import the data from a graphml file into Gephi but the attributes are not loaded properly. 我试图将数据从graphml文件导入Gephi,但属性未正确加载。 An example of this problem (with only one node and no edges): 此问题的一个示例(只有一个节点,没有边):

<?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 attr.name="g" attr.type="long" for="edge" id="d10" />
  <key attr.name="r" attr.type="long" for="edge" id="d9" />
  <key attr.name="b" attr.type="long" for="edge" id="d8" />
  <key attr.name="g" attr.type="long" for="node" id="d7" />
  <key attr.name="b" attr.type="long" for="node" id="d6" />
  <key attr.name="y" attr.type="double" for="node" id="d5" />
  <key attr.name="size" attr.type="double" for="node" id="d4" />
  <key attr.name="r" attr.type="long" for="node" id="d3" />
  <key attr.name="x" attr.type="double" for="node" id="d2" />
  <key attr.name="z" attr.type="double" for="node" id="d1" />
  <key attr.name="label" attr.type="string" for="node" id="d0" />
  <graph edgedefault="undirected">
    <node id="Node 1">
      <data key="d0">Node 1</data>
      <data key="d1">0.0</data>
      <data key="d2">-430.34348</data>
      <data key="d3">255</data>
      <data key="d4">10.0</data>
      <data key="d5">-32.351364</data>
      <data key="d6">0</data>
      <data key="d7">0</data>
    </node>
</graph>
</graphml>

Note: the file is generated by networkx so I do not have too much control over the order of the attributes 注意:该文件是由networkx生成的,因此我对属性的顺序没有太多控制

Once I import this file into Gephi, when I inspect the attributes I see that: 将文件导入Gephi后,在检查属性时会看到:

size = 4
x,y,z = (0,0,0)
r,g,b = (0,0,0)
Id = Node 1
Label = 255

If I run the same code again (and NetworkX will write the keys in different order) other other attributes will be read incorrectly) 如果我再次运行相同的代码(并且NetworkX将以不同的顺序写入密钥),则其他其他属性将被错误地读取)

For generating the graphml I use something like: 为了生成graphml,我使用了类似的方法:

nodeid = 'Node 1'
G = nx.Graph()
G.add_node(nodeid)
G.node[nodeid]['label'] = nodeid
G.node[nodeid]['size'] = 4
G.node[nodeid]['x'] = -430.34348
G.node[nodeid]['y'] = -32.351364
G.node[nodeid]['z'] = 0.0
G.node[nodeid]['r'] = 255
G.node[nodeid]['g'] = 0
G.node[nodeid]['b'] = 0
nx.write_graphml(G, 'test.graphml')

Is there a way to: 有没有办法:

1) convince Gephi to load the attributes correctly 1)说服Gephi正确加载属性

2) convince NetworkX to write (in the graphml file) the attributes alphabetically sorted ? 2)说服NetworkX编写(在graphml文件中)按字母顺序排序的属性?

确认上述问题为错误,并已在Gephi 0.9.2版本中修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM