Hi tiago,
I was thinking if there is an efficient way to assing values to a vector property map. The only working method that I can use is the following: vprop = g.new_vertex_property("vector<double>") for i in range(G.num_vertices()): vprop[G.vertex(i)] = [1,2,3] When I try to use something like this: index = np.where(some condition on vertex properties)[0] vprop.a[index] = [1,2,3] It gives me the error: "TypeError: 'NoneType' object does not support item assignment". The error comes only with vector< > type properties. I am using this to assing colours to some vertices if a given condition is satified. I hope that you can help, because the first method is really slow on graphs with hundred of thousands vertices.  Sent from: http://maindiscussionlistforthegraphtoolproject.982480.n3.nabble.com/ _______________________________________________ graphtool mailing list [hidden email] https://lists.skewed.de/mailman/listinfo/graphtool 
Ni! Hello Bleak, I trust two possible solutions to your question stand in plain sight in the sections of the documentation pertaining to property maps. I'm sure you'll remember to consult it more carefully in the future (= Cheers, ale .~´ On Sat, Jun 13, 2020 at 6:44 PM BleakHeart <[hidden email]> wrote: Hi tiago, _______________________________________________ graphtool mailing list [hidden email] https://lists.skewed.de/mailman/listinfo/graphtool 
Hi alexandre,
Thank you for the reply. I understood the get_2d_array(), but I am trying to understand how to use the set_2d_array() in my code. For example if do: G = Graph() G.add_vertex(10) vprop = G.new_vertex_property("vector<double>") vprop[G.vertex(1)] = [1,1,0,1] The vprop.get_2d_array(pos=[0,1,2,3]) gives me an array of shape (4, G.num_vertices()) where the elements placed in the second column are [1,1,0,1] and the other elements are zeros. In my code I will need to assing to specified vertices an array and I can't understand how to use the pos attribute in the set_2d_array(), because, for example, if I use set_2d_array(np.array([0.5, 0.2, 0.1, 1]), pos=[0,1,2,3]), it assigns to each row of the property map an element of the given array. Is there a way to select the rows and the columns of the property map?  Sent from: http://maindiscussionlistforthegraphtoolproject.982480.n3.nabble.com/ _______________________________________________ graphtool mailing list [hidden email] https://lists.skewed.de/mailman/listinfo/graphtool 
Administrator

Am 14.06.20 um 10:32 schrieb BleakHeart:
> In my code I will need to assing to specified vertices an array and I can't > understand how to use the pos attribute in the set_2d_array(), because, for > example, if I use set_2d_array(np.array([0.5, 0.2, 0.1, 1]), pos=[0,1,2,3]), > it assigns to each row of the property map an element of the given array. The set_2d_array() method expects a *TWO DIMENSIONAL* array of shape (M, N), where N is the number of vertices, and M in the size of the property vector for each vertex. > Is there a way to select the rows and the columns of the property map? Not without looping and assiging them one by one.  Tiago de Paula Peixoto <[hidden email]> _______________________________________________ graphtool mailing list [hidden email] https://lists.skewed.de/mailman/listinfo/graphtool signature.asc (849 bytes) Download Attachment

Tiago de Paula Peixoto <tiago@skewed.de> 
Free forum by Nabble  Edit this page 