[graph-tool] Performance question

Tiago de Paula Peixoto tiago at skewed.de
Fri Mar 21 11:03:32 CET 2014


On 03/21/2014 10:30 AM, Hang Mang wrote:
> Indeed out_degree() is very very slow. I just replaced it with a constant and it finished the computation in 0.5 seconds compared to the 2.7 minutes!!! But I guess what you mentioned is also slow since 'graph.degree_property_map('out')[i]' since assumes 'i' is a vertex object and not the index of the vertex. In that case I need to call graph.vertex(index) and get the vertex and then call degree_property_map('out')[vertex]. I guess this is still very slow!

You can also access scalar property maps with indexes instead of
descriptors. The following two are equivalent:

    d = g.degree_property_map("out")
    k = d[g.vertex(0)]  # degree of vertex 0
    k = d.a[0]          # degree of vertex 0

Best,
Tiago

-- 
Tiago de Paula Peixoto <tiago at skewed.de>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <https://lists.skewed.de/pipermail/graph-tool/attachments/20140321/0c9c2000/attachment.asc>


More information about the graph-tool mailing list