I have calculated the optimal number of networks for each node by using igraph, and here is the code I used.
import igraph
g = igraph.Graph.Read_Ncol('data.txt')
dendrogram = g.community_edge_betweenness()
clusters = dendrogram.as_clustering()
membership = clusters.membership
And now I would like to use the set_node_attributes function in networkX to tag each node with its number of communities. So if I run nx.get_node_attributes(g,'counts') it should produce
{123: 2,
124: 3,
125: 4 and so on} where "123" is a node and "2" is the count associated
I am thinking to use a for loop here but am not sure how to get started.
EDITED:
membership
#output:
[2,
3,
4]