Navin Navin - 1 month ago 19
R Question

What is membership in community detection?

I am finding it hard to understand what membership and modularity returns and why is it exactly used.

wc <- walktrap.community(karate)
modularity(wc)
membership(wc)
plot(wc, karate)


for the above code I get the following when I execute
membership
:

[1] 1 1 2 1 5 5 5 1 2 2 5 1 1 2 3 3 5 1 3 1 3 1 3 4 4 4 3 4 2 3 2 2 3


for the above code I get the following when I execute
modularity
:

[1] 0.3532216


I read the documentation but still a bit confusing.

Answer

The result of walktrap.community is a partition of your graph into communities which are numbered with id's from 1 to 5 in your case. The membership function gives a vector of a community ids for every node in your graph. So in your case node 1 belongs to community 1, and node 3 belongs to community 2.

The partition of the graph into communities is based on optimizing a so called modularity function. When you call modularity you get the final value of that function after the optimization process is complete. A high value of modularity indicates a good partition of the graph into clear communities, while a low value indicates the opposite.