# Generate a list of adjacency matrices
## Sub-network sizes
N <- c(250, 370, 120)
## Rate of friendship
p <- c(0.2, 0.15, 0.18)
## Network data
u <- unlist(lapply(1:3, function(x) rbinom(N[x] * (N[x] - 1), 1, p[x])))
W <- vec.to.mat(u, N)
# Convert W into a list of row-normalized matrices
G <- norm.network(W)
# Recover u
v <- mat.to.vec(G, ceiled = TRUE)
all.equal(u, v)
Run the code above in your browser using DataLab