Sampling from a hierarchical stochastic block model of networks.
sample_hierarchical_sbm(n, m, rho, C, p)
Integer scalar, the number of vertices.
Integer scalar, the number of vertices per block. n / m
must
be integer. Alternatively, an integer vector of block sizes, if not all the
blocks have equal sizes.
Numeric vector, the fraction of vertices per cluster, within a
block. Must sum up to 1, and rho * m
must be integer for all elements
of rho. Alternatively a list of rho vectors, one for each block, if they are
not the same for all blocks.
A square, symmetric numeric matrix, the Bernoulli rates for the
clusters within a block. Its size must mach the size of the rho
vector. Alternatively, a list of square matrices, if the Bernoulli rates
differ in different blocks.
Numeric scalar, the Bernoulli rate of connections between vertices in different blocks.
Passed to sample_hierarchical_sbm
.
An igraph graph.
The function generates a random graph according to the hierarchical stochastic block model.
# NOT RUN {
## Ten blocks with three clusters each
C <- matrix(c(1 , 3/4, 0,
3/4, 0, 3/4,
0 , 3/4, 3/4), nrow=3)
g <- sample_hierarchical_sbm(100, 10, rho=c(3, 3, 4)/10, C=C, p=1/20)
g
if (require(Matrix)) { image(g[]) }
# }
Run the code above in your browser using DataLab