简体   繁体   中英

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.

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 (ie, people can be divided in communities in different ways). This depends on the algorithm that you choose.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM