How do I find cluster assignment of a given node?


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.


See here for the docs:

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.

A post was split to a new topic: How to find cluster assignment of a node?