[graph-tool] Performance question

Guillaume Gay guillaume at mitotic-machine.org
Fri Mar 21 11:05:37 CET 2014


Sure, that escaped me!

Thanks for pointing this out (and now I might need to look back at my 
code to see if I don't do that kind of thing ;-))

Best,

Guillaume
Le 21/03/2014 11:00, Tiago de Paula Peixoto a écrit :
> On 03/21/2014 10:10 AM, Guillaume Gay wrote:
>> Hi,
>>
>> There is a propertymap that contains the out degrees of each vertex, it might be much faster to access it, i.e.:
>>
>> `i_degree = graph.degree_property_map('out')[i]`
> This is not a good idea, since "g.degree_property_map('out')" will
> create an entire property map anew (which is O(N)) each time you want a
> single degree (which should be O(1)). It is best to compute the property
> map before the loop, and just look it up when you need it.
>
>      d = graph.degree_property_map('out') # this is O(N)
>      ...
>
>      k = d[v]  # this is O(1)
>
> Best,
> Tiago
>
>
>
> _______________________________________________
> graph-tool mailing list
> graph-tool at skewed.de
> http://lists.skewed.de/mailman/listinfo/graph-tool

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.skewed.de/pipermail/graph-tool/attachments/20140321/16ad08aa/attachment.htm>


More information about the graph-tool mailing list