我尝试使用igraph包来自R的边缘社区结构检测方法。我希望" cut"我想要的聚类树。我该怎么做?它甚至可能吗?我没有从指南中了解默认值" cut"聚类树。谁能给我更多细节呢?
答案 0 :(得分:3)
您可以使用cutat()
函数剪切来自分层社区检测方法的树形图。函数membership()
也会剪切树,但它只能在单个点上剪切,最大模块化值:
g <- nexus.get("karate")
ebc <- edge.betweenness.community(g)
membership(ebc)
# Mr Hi Actor 2 Actor 3 Actor 4 Actor 5 Actor 6 Actor 7 Actor 8
# 1 1 2 1 3 3 3 1
# Actor 9 Actor 10 Actor 11 Actor 12 Actor 13 Actor 14 Actor 15 Actor 16
# 4 2 3 1 1 2 4 4
# Actor 17 Actor 18 Actor 19 Actor 20 Actor 21 Actor 22 Actor 23 Actor 24
# 3 1 4 1 4 1 4 5
# Actor 25 Actor 26 Actor 27 Actor 28 Actor 29 Actor 30 Actor 31 Actor 32
# 5 5 6 5 2 6 4 4
# Actor 33 John A
# 4 4
使用cutat()
,您可以将其剪切为一定数量的社区,例如在这种情况下3:
cutat(ebc, no = 3)
# [1] 2 2 1 2 2 2 2 2 1 1 2 2 2 1 1 1 2 2 1 2 1 2 1 3 3 3 1 3 1 1 1 1 1 1
或者您可以指定要执行的合并步骤的数量。这里我们执行15次合并:
cutat(ebc, steps = 15)
# [1] 3 3 2 3 4 5 5 3 1 9 4 10 11 2 12 13 5 14 15 16 17 18 19 6 7
# [26] 6 8 7 2 8 1 1 1 1
不幸的是, cutat()
没有为结果指定名称。