In R, I would like to create sets of simulated networks (matrix of interactions with 0 = no interaction and 1 = interaction) with varying modularity, but I don't find any function where networks can be created with given structural metrics.
I managed to create for instance fully nested structures with:
make_interaction_matrix_fullynested <- function(nspp) {
mat <- matrix(1, nspp, nspp)
mat[upper.tri(mat)] <- 0
output <- mat[nspp:1,]
return(output)
}
So I can vary the size of the network (nspp) but it will always have the same nestedness.
Could we imagine something similar for modularity? My goal is to simulate a set of high-modular and moderately-modular networks. The function would ideally work as the example above, where we can give a number of species and obtain always high-modular networks, or moderately-modular ones.
Thank you very much for your help in advance.