I'm tyring to use Networkx to visualize a distance matrix. What I want is a graph where the edge length between nodes is proportional to the distance between them in the distance matrix. I wrote the following code but it does not look like the resulting network takes the distance matrix into account at all. For instance, there are a few nodes that have distance of zero between them and they are not close at all in the resulting graph. How do I make this work?
names,data=loadDataSet()
#get distance matrix
dist_mat=cdist(data,data)
G=nx.from_numpy_matrix(dist_mat)
mapping=dict(zip(G.nodes(),names))
G = nx.relabel_nodes(G,mapping)
nx.draw(G)
pl.show()