I'd like to specify the coordinates of the vertices of a graph in graph-tool in an efficient way.
Given a csv which looks like:
Node,X,Y
1,2.5,3.8
2,3.4,2.9
...
I'd like graph-tool to plot vertex 1 at position (2.5,3.8) etc...
A non efficient solution is given in : Explicit vertex position in python graph-tool , so I can basically use a for loop over all my coordinates and save them in the property map 'pos'. If my graph is 'g' and my csv is read using pandas in the dataframe 'coordinates', I can do:
for i in range(1,numnodes+1):
pos[g.vertex(i)] = (coordinates.values[i-1,1],coordinates.values[i-1,2])
The problem is that my number of nodes, numnodes is big (~10^7), and this can take some time.
Is there a more efficient way to do this operation by inputting directly the data in the property map 'pos' ?
Aucun commentaire:
Enregistrer un commentaire