Get startedGet started for free

Fast-greedy community detection

The first community detection method you will try is fast-greedy community detection. You will use the Zachary Karate Club network. This social network contains 34 club members and 78 edges. Each edge indicates that those two club members interacted outside the karate club as well as at the club. Using this network you will determine how many sub-communities the network has and which club members belong to which subgroups. You will also plot the networks by community membership.

This exercise is part of the course

Network Analysis in R

View Course

Exercise instructions

  • Use the function fastgreedy.community() to create a community object. Assign this to the object kc.
  • Use the function sizes() on kc to determine how many communities were detected and how many club members are in each.
  • Display which club members are in which community using the function membership().
  • Make the default community plot by using the function plot(). The first argument should be the object kc and the second argument is the graph object g.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Perform fast-greedy community detection on network graph
kc = ___(g)

# Determine sizes of each community
___(___)

# Determine which individuals belong to which community
___(___)

# Plot the community structure of the network
___(___, g)
Edit and Run Code