簡體   English   中英

將NetworkX生成的GraphML數據導入Gephi

[英]Import NetworkX generated GraphML data to Gephi

我試圖將數據從graphml文件導入Gephi,但屬性未正確加載。 此問題的一個示例(只有一個節點,沒有邊):

<?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>

注意:該文件是由networkx生成的,因此我對屬性的順序沒有太多控制

將文件導入Gephi后,在檢查屬性時會看到:

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

如果我再次運行相同的代碼(並且NetworkX將以不同的順序寫入密鑰),則其他其他屬性將被錯誤地讀取)

為了生成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')

有沒有辦法:

1)說服Gephi正確加載屬性

2)說服NetworkX編寫(在graphml文件中)按字母順序排序的屬性?

確認上述問題為錯誤,並已在Gephi 0.9.2版本中修復。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM