I am trying to customize a graph using networkX (for use in gexf format). But I have not been able to set the shape of the node. Using the example here

import sys
import urllib2
import networkx as nx
data = urllib2.urlopen('http://gexf.net/data/viz.gexf')
G = nx.read_gexf(data)

print G.node['a']

G.node['a']['viz']['position']['x']=10
G.node['a']['viz']['position']['y']=20

# now my addition 
G.node['a']["viz"]['shape'] = 'disc'

print G.node['a'] this seems to work

but I can't write the file

nx.write_gexf(G,sys.stdout)

the error is :

# AttributeError: 'str' object has no attribute 'get'

Am I missing something ?

有帮助吗?

解决方案

It's a bug in the GEXF format writer.

Hopefully fixed now: https://github.com/networkx/networkx/pull/875

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top