2013-04-22 40 views
6

我想不通爲什麼degree.distribution不適合我。我試過R i386 3.0.0和R x64 3.0.0。下面是一個簡單的腳本生成一個圖表,並顯示其分佈:R graph degree.distribution不起作用

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) 

testG顯示:IGRAPH D--- 10 7 --(有意義)。 testD顯示:NULL(爲什麼?)。 該圖只有(1,1)處的一個值。但該圖包含具有其他度數的節點,如度數(testG)的輸出即[1,3,2,4,2,2,0,0,0,0]所證明。

+4

這是一個錯誤:您可以將其報告給軟件包作者。該函數使用'hist',其結果曾經有一個'intensityities'字段,但它在R 3.0.0中被刪除(可以使用'density'代替)。 – 2013-04-22 18:03:15

+0

謝謝!我懷疑可能是這種情況。在R x64 2.15.2上運行我的腳本完美地工作。 – user1748601 2013-04-22 18:16:50

+4

已經被報告和修復:https://bugs.launchpad.net/igraph/+bug/1164523作爲一種解決方法,定義您自己的'degree.distribution'函數,非常簡單,您可以從igraph中複製它,然後更改'強度「到」密度「。 – 2013-04-22 19:35:05

回答