如何根据 cluster_edge_ Betweenness 输出删除边

问题描述 投票:0回答:1

我想按照here的要求做同样的事情,使用问题中的第一种方法。

遗憾的是,以下行中的

mods
变量未定义,我问自己如何调整:

g2 <- delete.edges(out, wc$removed.edges[seq(length = which.max(mods) - 1)])

但是,我猜函数

edge.betweenness.community
是旧的,我使用的新版本调整如下:

wc <- cluster_edge_betweenness(out, weights = (E(out)$value, directed = FALSE, bridges = TRUE, membership = TRUE, modularity = TRUE)

然而,我很难调整

delete.edge
功能 – 第一次调用删除了太多边,第二次调用删除了太多边:

out2 <- delete.edges(out, wc$removed.edges[seq(length = which.max(wc$modularity))])
out2 <- delete.edges(out, wc$removed.edges[which.max(wc$modularity)])

为了完整起见,我添加了引用问题中的数据:

from   to  value sourceID targetID
1    74   80 0.2829   255609   262854
2    74   61 0.2880   255609   179585
3    80 1085 0.2997   262854  3055482
4  1045 1046 0.1842  2970629  2971615
5  1046 1085 0.2963  2971615  3055482
6  1046 1154 0.2714  2971615  3087803
7  1085 1154 0.2577  3055482  3087803
8  1085 1187 0.2850  3055482  3101131
9  1085 1209 0.2850  3055482  3110186
10 1154 1243 0.2577  3087803  3130848
11 1154 1187 0.2305  3087803  3101131
12 1154 1209 0.2305  3087803  3110186
13 1154 1244 0.2577  3087803  3131379
14 1243 1187 0.1488  3130848  3101131
15 1243 1209 0.1488  3130848  3110186
16 1243 1244 0.1215  3130848  3131379
17 1243 1281 0.2997  3130848  3255811
r cluster-analysis igraph
1个回答
1
投票

我认为您可以使用

delete.edges
+
disjoint_union
,而不是使用
induced_subgraph
,如下所示

g <- graph_from_data_frame(df)
ceb <- cluster_edge_betweenness(g)
out <- do.call(
  disjoint_union,
  lapply(groups(ceb), \(x) induced_subgraph(g, x))
)

情节看起来像

par(mfrow = c(2, 1))
plot(ceb, g, main = "Edge betweenness")
plot(cluster_edge_betweenness(out), out, main = "Disjoint union")

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.