Pseudocode for getCommunityMatrix