Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R graph degree.distribution not working

I cannot figure out why degree.distribution is not working for me. I have tried on R i386 3.0.0 and R x64 3.0.0. Here is the simple script to generate a graph and show its 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 shows: IGRAPH D--- 10 7 -- (makes sense). testD shows: NULL (why?). The plot is with just one value at (1,1). But the graph contains nodes with other degrees, as evidenced by the output of degree(testG), which is [1,3,2,4,2,2,0,0,0,0].

like image 507
user1748601 Avatar asked Apr 22 '13 17:04

user1748601


1 Answers

You have to modify the degree.distribution function. Details can be find on following link. Can't replicate result with degree.distribution function of igraph

like image 110
Shradha Avatar answered Sep 18 '22 23:09

Shradha