如何用R中的igraph计算加权度分布?

min*_*nda 9 r igraph

考虑一个数据帧df,其中前两列是节点对,连续列V1,V2... Vn表示节点之间的流(可能为0,表示该列的网络没有边缘).我想使用流量作为权重来进行度,社区检测和其他网络测量的分析.

然后在V1I中分析关于权重的图表:

# create graph and explore unweighted degrees with respect to V1
g <- graph.data.frame( df[df$V1!=0,] )
qplot(degree(g))
x <- 0:max(degree(g))
qplot(x,degree.distribution(g))

# set weights and explore weighted degrees using V1
E(g)$weights <- E(g)$V1
qplot(degree(g))
Run Code Online (Sandbox Code Playgroud)

第三个qplot的输出与第一个没有什么不同.我究竟做错了什么?

更新:

所以graph.strength我正在寻找,但graph.strength(g)在我的情况下给出标准度输出后跟:

Warning message:
In graph.strength(g) :
At structural_properties.c:4928 :No edge weights for strength calculation,
normal degree
Run Code Online (Sandbox Code Playgroud)

我必须正确设置重量,这是不够的E(g)$weights <- E(g)$V1,为什么g$weights不同E(g)$weights

Sac*_*amp 7

该函数graph.strength可以给出带有weights参数的权重向量.我想在你的代码去错了是你要调用的权重属性E(g)$weight不是E(g)$weights.