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
On 01/04/2013 10:35 AM, Kire Gasteovski wrote:
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.
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 -- Tiago de Paula Peixoto <tiago@skewed.de>
Le 04/01/2013 10:35, Kire Gasteovski a écrit :
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@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
participants (3)
-
Guillaume Gay -
Kire Gasteovski -
Tiago de Paula Peixoto