Sampling from the stochastic block model of networks
sample_sbm(n, pref.matrix, block.sizes, directed = FALSE, loops = FALSE)
sbm(...)Number of vertices in the graph.
The matrix giving the Bernoulli rates. This is a \(K\times K\) matrix, where \(K\) is the number of groups. The probability of creating an edge between vertices from groups \(i\) and \(j\) is given by element \((i,j)\). For undirected graphs, this matrix must be symmetric.
Numeric vector giving the number of vertices in each group. The sum of the vector must match the number of vertices.
Logical scalar, whether to generate a directed graph.
Logical scalar, whether self-loops are allowed in the graph.
Passed to sample_sbm().
An igraph graph.
This function samples graphs from a stochastic block model by (doing the
equivalent of) Bernoulli trials for each potential edge with the
probabilities given by the Bernoulli rate matrix, pref.matrix.
The order of the vertices in the generated graph corresponds to the
block.sizes argument.
Faust, K., & Wasserman, S. (1992a). Blockmodels: Interpretation and evaluation. Social Networks, 14, 5–61.
Random graph models (games)
bipartite_gnm(),
erdos.renyi.game(),
sample_(),
sample_bipartite(),
sample_chung_lu(),
sample_correlated_gnp(),
sample_correlated_gnp_pair(),
sample_degseq(),
sample_dot_product(),
sample_fitness(),
sample_fitness_pl(),
sample_forestfire(),
sample_gnm(),
sample_gnp(),
sample_grg(),
sample_growing(),
sample_hierarchical_sbm(),
sample_islands(),
sample_k_regular(),
sample_last_cit(),
sample_pa(),
sample_pa_age(),
sample_pref(),
sample_smallworld(),
sample_traits_callaway(),
sample_tree()
## Two groups with not only few connection between groups
pm <- cbind(c(.1, .001), c(.001, .05))
g <- sample_sbm(1000, pref.matrix = pm, block.sizes = c(300, 700))
g
#> IGRAPH 9173a89 U--- 1000 17014 -- Stochastic block model
#> + attr: name (g/c), loops (g/l)
#> + edges from 9173a89:
#> [1] 3-- 7 4-- 7 2-- 8 3--10 1--11 3--11 7--11 10--11 2--12 5--12
#> [11] 7--13 7--14 9--15 5--16 8--16 3--18 15--18 3--19 8--20 3--21
#> [21] 10--21 15--21 3--22 7--22 22--23 1--24 4--24 5--25 12--25 23--25
#> [31] 1--26 11--26 15--26 18--26 22--26 9--27 14--27 11--28 2--29 11--29
#> [41] 4--30 10--30 13--30 29--30 7--31 15--31 8--32 2--33 4--33 23--33
#> [51] 5--35 29--35 16--36 22--36 32--36 34--36 9--37 20--37 31--37 6--38
#> [61] 9--38 21--38 4--39 8--39 16--39 30--40 35--40 4--41 5--41 14--41
#> [71] 23--41 25--41 32--41 40--41 1--42 14--42 25--42 13--43 14--43 17--43
#> + ... omitted several edges