rSBM: Sample of a binary Stochastic Block Model (SBM)

Description Usage Arguments Value Examples

View source: R/sampling_sbm.R

Description

This function samples a realization of a stochastic block model from a set a user-defined parameters in a igraĥ format.

Usage

1
rSBM(nbNodes, connectParam, blockProp)

Arguments

nbNodes

number of nodes in the graph

connectParam

inter and intra block connection probabilities

blockProp

proportion of node in each block of the SBM

Value

an igraph object with a vertex attribute called "memberships" for block belonging

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## graph parameters
nNodes  <- 90
blockProp <- c(.5, .25, .25)   # group proportions
nbBlock   <- length(blockProp) # number of blocks
connectParam <- diag(.4, nbBlock) + 0.05 # connectivity matrix: affiliation network

## Graph Sampling
mySBM <- rSBM(nNodes, connectParam, blockProp)

## Graph plotting
plot(mySBM, vertex.color = igraph::V(mySBM)$memberships)

jchiquet/rggm documentation built on April 5, 2020, 1:53 a.m.