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]
.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With