R graph degree.distribution不起作用

use*_*601 7 r graph distribution igraph

我无法弄清楚为什么degree.distribution不适合我.我试过R i386 3.0.0和R x64 3.0.0.以下是生成图形并显示其分布的简单脚本:

library(igraph)

testG = graph.empty(n=10, directed=TRUE)
for(row in 1 : 5) {
    src = row
    dest = row + 1
    testG = add.edges(testG, rbind(src, as.numeric(dest)))
    if(row %% 2 == 0) {
        dest = row + 2
        testG = add.edges(testG, rbind(src, as.numeric(dest)))
    }
}
testG

testD = degree.distribution(testG, v=V(testG), cumulative=FALSE)
testD
plot(1 : length(testD), testD, "h", main="Website Graph Degree Distribution", xlab="Degree", ylab="Probability of Degree")
degree(testG)
Run Code Online (Sandbox Code Playgroud)

testG显示:( IGRAPH D--- 10 7 --有道理).testD显示:( NULL为什么?).该图只有一个值(1,1).但是图表包含具有其他度数的节点,如度数(testG)的输出所证明的那样[1,3,2,4,2,2,0,0,0,0].

小智 1

您必须修改 Degree.distribution 函数。详细信息可以在以下链接中找到。 无法使用 igraph 的 Degree.distribution 函数复制结果