0
我必须在网络中检测社区。但我需要告知社区数量(k)。Python中的社区检测
我想这
from igraph import *
karate = Nexus.get("karate")
cl = karate.community_fastgreedy()
cl.as_clustering().membership
# [0, 1, 1, 1, 0, 0, 0, 1, 2, 1, 0, 0, 1, 1, 2, 2, 0, 1, 2, 0,
# 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
但是,我想告诉社区
公式:
from igraph import *
karate = Nexus.get("karate")
k = 2 # --> Number of communities
cl = karate.community_fastgreedy(k) # --> Note the k
我如何做到这一点的数量?有没有一些算法呢?我可以使用'Networkx'或'igraph'。