x <- matrix(runif(25 * 25), 25, 25)
x <- symmetrize(x)
diag(x) <- 0
densities <- seq(0.05, 0.55, by=0.1)
threshes <- get_thresholds(x, densities)
## Verify that the densities are correct
graphs <- lapply(threshes, function(th) {
graph_from_adjacency_matrix(x * (x > th), mode='undirected',
diag=FALSE, weighted=TRUE)
})
sapply(graphs, graph.density)
Run the code above in your browser using DataLab