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

hello,How to take out the vertex after community-discovery? #121

Closed swx-10 closed 1 year ago

swx-10 commented 1 year ago

After I do community discovery, how can I take out these vertices in each community?

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

Looking forward to your response!

ragibson commented 1 year ago

Your question isn't entirely clear, but the answer to your question can be found in the documentation's introduction. That is the best resource for these sorts of simple questions.

Indeed, the sentence immediately below the one you quote mentions that the partition is derived from igraph's VertexClustering class, so it inherits the membership attribute. That contains the community labels for each vertex.

vtraag commented 1 year ago

Thanks @ragibson!

If anyone is curious to understand how to use VertexClustering, you can refer to the documentation of igraph. In particular, the Clustering (from which VertexClustering derives) describes the usage quite clearly: https://igraph.org/python/api/latest/igraph.clustering.Clustering.html.