# Generate a list of adjacency matrices
## sub-network size
N <- c(250, 370, 120)
## rate of friendship
p <- c(.2, .15, .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 G 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