Gray Benson
Gray Benson

Reputation: 1

Is there a way to group nodes in a Networkx graph together based on how connected they are?

I have 39 people who have listed preferences for who they would like to be in a group with. I have input this data into a NetworkX graph in Python. I want to use the NetworkX graph to create groups of three based off how people are connected to eachother.

Upvotes: 0

Views: 876

Answers (1)

Riccardo Bucco
Riccardo Bucco

Reputation: 15364

You are trying to identify communities. Here is a possible solution (G is your graph, built using the networkx module):

from networkx.algorithms.community import greedy_modularity_communities

c = list(greedy_modularity_communities(G))

You can get very different outputs (i.e., people can be divided in communities in different ways). This depends on the algorithm that you choose.

Upvotes: 1

Related Questions