Learn R Programming

nett (version 1.0.0)

fast_sbm: Sample from a SBM (fast)

Description

Samples an adjacency matrix from a stochastic block model (SBM)

Usage

fast_sbm(z, B)

Value

An adjacency matrix following SBM

Arguments

z

Node labels (\(n * 1\))

B

Connectivity matrix (\(K * K\))

Details

The function implements a fast algorithm for sampling sparse SBMs, by only sampling the necessary nonzero entries. This function is adapted almost verbatim from the original code by Aiyou Chen.

Examples

Run this code
B = pp_conn(n = 10^4, oir = 0.1, lambda = 7, pri = rep(1,3))$B
head(fast_sbm(sample(1:3, 10^4, replace = TRUE), B))

Run the code above in your browser using DataLab