Your g.xml
GraphML 文件看起来不错,可以加载到 Cytoscape 中(我使用的是 Mac)。您是否安装了图形阅读器 https://code.google.com/p/graphmlreader/插入?
如果没有,请下载它并将其放入插件文件夹中,然后重新启动 Cytoscape 并尝试加载g.xml
再次网络。
Update以下是一些将图形外观和定位添加到 networkx 图形的代码。它有点冗长,您可以根据需要省略一些属性:
import networkx as nx
G = nx.Graph()
G.add_edge(0, 1, weight=0.1, label='edge', graphics={
'width': 1.0, 'fill': '"#0000ff"', 'type': '"line"', 'Line': [],
'source_arrow': 0, 'target_arrow': 0})
nx.set_node_attributes(G, 'graphics', {
0: {'x': -85.0, 'y': -97.0, 'w': 20.0, 'h': 20.0,
'type': '"ellipse"', 'fill': '"#889999"', 'outline': '"#666666"',
'outline_width': 1.0},
1: {'x': -16.0, 'y': -1.0, 'w': 40.0, 'h': 40.0,
'type': '"ellipse"', 'fill': '"#ff9999"', 'outline': '"#666666"',
'outline_width': 1.0}
})
nx.set_node_attributes(G, 'label', {0: "0", 1: "1"})
nx.write_gml(G, 'network.gml')
Result: