[graph-tool] ranking vertices by value of vertex property

Tiago de Paula Peixoto tiago at skewed.de
Tue Jul 7 16:29:37 CEST 2020


Am 07.07.20 um 15:39 schrieb Ioana K-Hulpus:
> Hi,
> I ran PageRank on my graph, and now I need to get the top-k highest scored.
> Is there any faster / more straightforward way of achieving this than by
> creating and then sorting a new dictionary, as in the following method?

Yes, you can access property map values as numpy arrays via the ".a"
attribute, e.g. if pr is a vertex property map with the pagerank scores,
then

   pr.a

will give you a numpy array. This means you can use the argsort() method
to obtain the indexes (i.e. vertices) in increasing order:

   pr.a.argsort()

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: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.skewed.de/pipermail/graph-tool/attachments/20200707/eb331e31/attachment.asc>


More information about the graph-tool mailing list