문제

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