我曾尝试在R中使用igraph中的'重新连接',但它仅适用于未加权的网络。任何帮助???
答案 0 :(得分:2)
我的igraph
版本很乐意重新连接加权图表:
g <- graph.ring(10)
E(g)$weight <- seq_len(ecount(g))
E(g)$weight
# [1] 1 2 3 4 5 6 7 8 9 10
is.weighted(g)
# [1] TRUE
g2 <- rewire(g,niter=3)
plot(g2)
is.weighted(g2)
# [1] TRUE
版本是:
packageDescription("igraph")$Version
# [1] "0.6.6"
答案 1 :(得分:1)
使用igraph的1.0.1
版本,请尝试以下操作:
# SAME EXAMPLE AS IN PREVIOUS ANSWER AND COMMENTS
g <- graph.ring(10)
E(g)$weight <- seq_len(ecount(g))
E(g)$weight
# [1] 1 2 3 4 5 6 7 8 9 10
is.weighted(g)
# [1] TRUE
g2 <- rewire(g, with=each_edge(0.5)) #rewire vertices with constant probability
E(g2)$weight <- sample(E(g)$weight) #shuffle initial weights and assign them randomly to edges
plot(g2)
is.weighted(g2)
# [1] TRUE
E(g2)$weight
# [1] 3 6 2 4 10 1 9 8 7 5
请注意,此方法可能会导致多边缘或循环。