2

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.

zx8754
  • 52,746
  • 12
  • 114
  • 209
Navin
  • 684
  • 1
  • 11
  • 24

1 Answers1

4

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.

Jim Raynor
  • 198
  • 2
  • 9
  • Thanks, Is it possible for us to manually set the modularity? – Navin Nov 07 '16 at 12:04
  • I don't think so. Modularity is a metric which you get as a result of partitioning the graph into communities. Many partitions can result into the same modularity score so you wouldn't know which to pick. – Jim Raynor Nov 11 '16 at 18:20