Export graph to graphml with node positions using NetworkX
I'm using NetworkX 1.9.1. I have a graph that I need to organize with positions and I then export to graphml format. I've tried code in this question . It does not work, here is my example import networkx as nx import matplotlib.pyplot as plt G = nx.read_graphml("colored.graphml") pos=nx.spring_layout(G) # an example of quick positioning nx.set_node_attributes(G, 'pos', pos) nx.write_graphml(G, "g.graphml") nx.draw_networkx(G, pos) plt.savefig("g.pdf") Here are the errors I get, the problem is how positions are saved (graphml does not accept arrays). C:\Anaconda\python.exe C:/Users/sturaroa