Hi everyone I 'd like to compute node coordinates and then export graph to GEXF and process it with Gephi. However when I run the following code
import networkx as nx
import numpy as np
....
area_ratios = [np.sum(new[:,0])/Stotal, np.sum(new[:,1])/Stotal, np.sum(new[:,2])/Stotal]
X = np.array([0, -sqrt(3)/2 * area_ratios[1] , sqrt(3)/2 * area_ratios[2]])
Y = np.array([ area_ratios[0], -1/2 * area_ratios[1] , -1/2 * area_ratios[2]])
point = (np.sum(X), np.sum(Y))
graph.add_node(node_name, {'x-coord': np.asscalar(point[0]*SCALE_FACTOR),
'y-coord': np.asscalar(point[1]*SCALE_FACTOR), 'size': Stotal*3})
nx.write_gexf(graph, PATH + 'mygraph.gexf')
it gives me a KeyError: <type 'numpy.float64'>
even though np.asscalar
is meant to convert the relevant attributes to the compatible python type.
Any ideas?
Stotal
? It works ok for me when I try usingnp.asscalar
on all three values. (or just defining Stotal as an int)