Skip to contents

Sampling from a hierarchical stochastic block model of networks.

Usage

sample_hierarchical_sbm(n, m, rho, C, p)

hierarchical_sbm(...)

Arguments

n

Integer scalar, the number of vertices.

m

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.

rho

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.

C

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.

p

Numeric scalar, the Bernoulli rate of connections between vertices in different blocks.

...

Passed to sample_hierarchical_sbm().

Value

An igraph graph.

Details

The function generates a random graph according to the hierarchical stochastic block model.

Author

Gabor Csardi csardi.gabor@gmail.com

hsbm_game(), hsbm_list_game().

Examples


## 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
#> IGRAPH e7b7c3c U--- 100 478 -- Hierarchical stochastic block model
#> + attr: name (g/c), m (g/n), rho (g/n), C (g/n), p (g/n)
#> + edges from e7b7c3c:
#>  [1]  1-- 2  1-- 3  2-- 3  1-- 4  2-- 4  3-- 4  1-- 5  3-- 5  1-- 6  2-- 6
#> [11]  4-- 7  6-- 7  5-- 8  6-- 8  4-- 9  5-- 9  6--10  7-- 8  7-- 9  8-- 9
#> [21]  8--10  9--10 11--12 11--13 12--13 12--14 13--14 12--15 13--15 12--16
#> [31] 13--16 14--17 15--17 16--17 14--18 15--18 16--18 14--19 15--19 16--19
#> [41] 14--20 16--20 17--19 18--19 17--20 19--20 21--22 21--23 22--23 21--24
#> [51] 22--24 23--24 21--25 22--25 21--26 22--26 23--26 24--27 25--27 26--27
#> [61] 24--28 25--28 26--28 24--29 25--29 26--29 25--30 27--29 28--29 27--30
#> [71] 29--30 31--32 31--33 32--33 31--34 32--34 31--35 32--35 33--35 33--36
#> + ... omitted several edges

library("Matrix")
image(g[])