![](/img/trans.png)
[英]How to group nodes in a networkx python graph based on note attributes?
[英]Is there a way to group nodes in a Networkx graph together based on how connected they are?
我有 39 個人列出了他們想與誰一起參加的偏好。 我已將此數據輸入到 Python 中的 NetworkX 圖中。 我想使用 NetworkX 圖根據人們彼此之間的聯系方式創建三人組。
您正在嘗試識別社區。 這是一個可能的解決方案( G
是您的圖表,使用networkx
模塊構建):
from networkx.algorithms.community import greedy_modularity_communities
c = list(greedy_modularity_communities(G))
您可以獲得非常不同的輸出(即,人們可以以不同的方式划分為社區)。 這取決於您選擇的算法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.