r: network randomization test igprah stakoverflow code example
Example: r: network randomization test igprah stakoverflow
g <- graph_from_data_frame(edges, directed=FALSE)
gd = edge_density(g)
g.apl <-mean_distance(g, directed=FALSE)
g.random <- erdos.renyi.game(n = gorder(g), p.or.m = gd, type = "gnp")
gl <- vector('list',1000)
for(i in 1:1000){
gl[[i]] <- erdos.renyi.game(n = gorder(g), p.or.m = gd, type = "gnp")
}
gl.apls <- unlist(lapply(gl, mean_distance, directed = FALSE))
hist(gl.apls, xlim = range(c(1.5, 10)))
abline(v = g.apl, col = "red", lty = 3, lwd = 2)
mean(gl.apls < g.apl)