[graph-tool] Accessing a compressed matrix is super slow!

Tiago de Paula Peixoto tiago at skewed.de
Fri Mar 21 12:32:38 CET 2014

On 03/21/2014 12:15 PM, Hang Mang wrote:
> Hi, I found that accessing a compressed matrix is really slow. I'm
> computing a similarity index called LHN1, it took 34 seconds to
> compute when I access the 'paths' variable/matrix. But when I
> converted paths to paths.asarray() it only took 11 seconds. So now I'm
> really ending up calling toarray() all over my code. I'm not sure of
> why using compressed matrices in the first place or how I could
> overcome this! Forget about the get_degrees_dic() for now.

This doesn't really have anything to do with graph-tool.

Compressed matrices are always slower then dense ones, but they take
less space. Please take a look at the scipy documentation for sparse


Read about the different types of sparse matrices (crs, lil, coo, etc.)
and their advantages, and disadvantages.

Since graphs are most often sparse, it makes more sense to return sparse
arrays. If the user wants dense ones, it is trivial to convert.


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/9215b1ba/attachment.asc>

More information about the graph-tool mailing list