How do I find cluster assignment of a given node?

Hi,

I used the below code to get a community, which has 136 clusters in my case.

# g is my igraph.Graph() with 1M nodes and 2M edges
community = g.community_fastgreedy().as_clustering()

How do I figure out which nodes are present in a given cluster/which cluster does a given node belong to? I somehow can’t figure out how to do this basic operation.

Thanks!

See here for the docs:

https://igraph.org/python/api/latest/igraph.clustering.Clustering.html

community[i] gives you the vertices belonging to cluster i (indexed from 0, as usual).

community.membership[v] gives you the cluster that contains vertex v. The membership property of the Clustering class is referred to as the “membership vector” in igraph.