Getting the coordinates from vertex property map

Guten Tag!

I am making the following example http://projects.skewed.de/graph-tool/wiki/FrontpageExample .

What I want to do is to extract the coordinates of the nodes into a list from the vertex property map (i.e. from the variable pos, I assume they are stored there). How do I do that? Please help me, because I am stuck on this problem for 2 days and I can't find the solution.

Best regards,
Kiril

attachment.html (1.66 KB)

You can either do:

   coords = []
   for v in g.vertices():
       x, y = pos[v]
       coords.append((x, y))

or the following if you want arrays:

   x, y = ungroup_vector_property(g, [0, 1])
   print(x.a) # array with x coordinates
   print(y.a) # array with y coordinates

Cheers,
Tiago

Guten Tag!

I am making the following example
http://projects.skewed.de/graph-tool/wiki/FrontpageExample .

What I want to do is to extract the coordinates of the nodes into a
list from the vertex property map (i.e. from the variable pos, I
assume they are stored there). How do I do that? Please help me,
because I am stuck on this problem for 2 days and I can't find the
solution.

Best regards,
Kiril

_______________________________________________
graph-tool mailing list
graph-tool(a)skewed.de
http://lists.skewed.de/mailman/listinfo/graph-tool

Hi,

In this case, if I recall well, the propery map |pos| has elements of
type |vector<double>|, so you can't access to the data through the

pos.a| attribute.

A simple loop will do though

pos_list = np.array([pos[v].afor vin g.vertices()])|

Hope it helps.

Guillaume

attachment.html (5.61 KB)