Created
February 28, 2017 03:01
-
-
Save mustafaascha/2cea94d3f96cb8434fca94cb659e0536 to your computer and use it in GitHub Desktop.
Make a bunch of networks whose links are a function of the binomial distribution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set.seed(12121212) | |
library(network) | |
nw_random <- function(prob, size_net) { | |
network(x = matrix(rbinom(size_net ^ 2, 1, prob = prob), ncol = size_net, nrow = size_net)) | |
} | |
library(ggnetwork) | |
nwp <- function(nw) { | |
ggplot(ggnetwork(nw, layout = "kamadakawai", cell.jitter = 0), | |
aes(x = x, y = y, xend = xend, yend = yend)) + | |
geom_edges() | |
} | |
library(tidyverse) | |
random_networks <- | |
pmap(list(1:16 / 32, 12), nw_random) | |
random_networks_projection <- | |
map(random_networks, nwp) | |
#nwp(random_networks[[4]]) | |
library(gridExtra) | |
do.call("grid.arrange", random_networks_projection) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment