I have an network that I would like to analyze using the edge_betweenness
community detection algorithm in igraph. I'm familiar with NetworkX, but am trying to learning igraph because of it's additional community detection methods over NetworkX.
My ultimate goal is to run edge_betweenness
community detection and find the optimal number of communities and write a CSV with community membership for each node in the graph.
Below is my code as it currently stands. Any help figuring out community membership is greatly appreciated.
input data ('network.txt'):
1 2
2 3
2 7
3 1
4 2
4 6
5 4
5 6
7 4
7 8
8 9
9 7
10 7
10 8
10 9
iGraph code
import igraph
# load data into a graph
g = igraph.Graph.Read_Ncol('network.txt')
# plot graph
igraph.plot(g)
# identify communities
communities = igraph.community_edge_betweenness()
# not really sure what to do next
num_communities = communities.optimal_count
communities.as_clustering(num_communities)
What do I need to do to find the optimal number of communities and write which community each node in the graph belongs to a list?