vtraag / leidenalg

Implementation of the Leiden algorithm for various quality functions to be used with igraph in Python.
GNU General Public License v3.0
575 stars 77 forks source link

retrieving the communities #90

Closed GENETAY closed 2 years ago

GENETAY commented 2 years ago

when I use the first command in the introduction

partition = la.find_partition(G, la.ModularityVertexPartition)

the variable partition is not (easily) usable. I don't manage it.: input: partition output: <leidenalg.VertexPartition.ModularityVertexPartition at 0x7f1fb751d4c0>

How to use it? I've read the source code and I've check the methods of the class of the variable "partition" without success.

I want something comparable to networkx, a dictionary of nodes with corresponding community, or something like a list with communities of points in the same order as nodes.

vtraag commented 2 years ago

The returned partition is based on the VertexClustering of igraph, you can check the documentation here: https://igraph.org/python/api/latest/igraph.clustering.VertexClustering.html.

In essence, you can get the list of the individual membership of each node using partition.membership. That is, if partition.membership[i] == c this indicates that node i belongs to community c. You can also index the partition directly, i.e. partition[c] gives you the list of nodes that belong to community c.

Hopefully this provides you enough to go on? I'll see if I can improve the documentation of leidenalg and point to the igraph documentation.

GENETAY commented 2 years ago

Hmm, thank you, indeed!! It is working. I managed to do my experiment.

I am quite busy at this moment but I can edit documention myself if you want.

vtraag commented 2 years ago

Hmm, thank you, indeed!! It is working. I managed to do my experiment.

OK, great, good to hear!

I am quite busy at this moment but I can edit documention myself if you want.

Same here :smile: Whomever comes first then I guess. I'll keep it open then for now

vtraag commented 2 years ago

I've added some explicit links to VertexClustering in the documentation in 8f68aba4c26986e128afe0954d2c7ae4cd49e734.

GENETAY commented 2 years ago

ok. thank you very much for your work!

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Garanti sans virus. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

Le mar. 22 févr. 2022 à 11:32, Vincent Traag @.***> a écrit :

Closed #90 https://github.com/vtraag/leidenalg/issues/90.

— Reply to this email directly, view it on GitHub https://github.com/vtraag/leidenalg/issues/90#event-6116977733, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN33DBDNB7MOLL6UJDJCPSLU4NQ3TANCNFSM5HU236NQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

-- GENETAY Edouard 06 14 36 20 62