Thanks Gareth, I will try to dig into this method!
Flavian,I’m not exactly sure what you’re trying to do, but it seems you want to select only a handful of vertices based on shortest distance calculations?
You could try something like this, which is IMHO very fast:# You already have your shortest paths, so you can probably skip this step, but it is possible to# search all shortest paths from a source vertex to all vertices within a certain distance, or to# search the shortest path from and to a specific vertex using the built-in shortest_distance function:v_localDist = shortest_distance(g, source=v, weights=e_dist, max_dist=dist)# You can then use the built-in masks functionality to filter out only relevant nodes.# First create the mask property map:v_mask = g.new_vertex_property('bool')# Then assign the property map values from another property map array, using .a / get_array() to access arrays:v_mask.a = v_localDist.a <= dist # set the array values to 1 (boolean property map) where distance parameter is met# Then activate the filterg.set_vertex_filter(v_mask) # activate mask based on currently selected vertices# And deactivate when doneg.set_vertex_filter(None)I use this method to iterate calculations on local vertex clusters (based on distance) within some fairly big graphs.GarethOn 16 Jul 2014, at 15:49, Flavien Lambert <petit.lepton@gmail.com> wrote:Hi Elliott, I know that the get_array is very efficient but the thing is I have to know exactly what are the edges I am dealing with.
To be more precise, I run loops over the shortest paths which I computed before and stored in a file. Therefore, each iteration makes access to a tiny fraction of the network and I must keep track of the edges involved. That is why I was giving the example of single access instead of global one though .a.
Best,
F.On 16 Jul 2014 22:04, "..." <offonoffoffonoff@gmail.com> wrote:_______________________________________________You know you can get the edges, vertices, and property maps as numpy arrays by using the .a method. You should be able to do whatever you need much faster with arrays than dictionaries.
On Jul 16, 2014 3:50 AM, "Flavien Lambert" <petit.lepton@gmail.com> wrote:Hi everyone, to compute some functions I needed to loop over a bunch of edges. I realized that the call to property maps seems slow compare to a dictionary. I am a bit surprised since I was told - I am not an expert in python - that a query in a dictionary was already. So I was wondering if I made a mistake in using graph_tool. Following is an example of comparison.
Best,F.
In [3]:In [4]:destination (vertex) (type: long double) _graphml_vertex_id (vertex) (type: string) origin (vertex) (type: long double) _graphml_edge_id (edge) (type: string) speed (edge) (type: long double) name (edge) (type: string) time (edge) (type: long double)In [5]:In [8]:CPU times: user 102 ms, sys: 5 ms, total: 107 ms Wall time: 103 ms CPU times: user 2 ms, sys: 0 ns, total: 2 ms Wall time: 1.94 ms
_______________________________________________
graph-tool mailing list
graph-tool@skewed.de
http://lists.skewed.de/mailman/listinfo/graph-tool
_______________________________________________
graph-tool mailing list
graph-tool@skewed.de
http://lists.skewed.de/mailman/listinfo/graph-tool
graph-tool mailing list
graph-tool@skewed.de
http://lists.skewed.de/mailman/listinfo/graph-tool
_______________________________________________
graph-tool mailing list
graph-tool@skewed.de
http://lists.skewed.de/mailman/listinfo/graph-tool