Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

retrieving the communities #90

Closed
GENETAY opened this issue Nov 9, 2021 · 5 comments
Closed

retrieving the communities #90

GENETAY opened this issue Nov 9, 2021 · 5 comments

Comments

@GENETAY
Copy link

GENETAY commented Nov 9, 2021

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
Copy link
Owner

vtraag commented Nov 9, 2021

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
Copy link
Author

GENETAY commented Nov 15, 2021

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
Copy link
Owner

vtraag commented Nov 16, 2021

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 😄 Whomever comes first then I guess. I'll keep it open then for now

@vtraag
Copy link
Owner

vtraag commented Feb 22, 2022

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

@vtraag vtraag closed this as completed Feb 22, 2022
@GENETAY
Copy link
Author

GENETAY commented Feb 22, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants