rustworkx.undirected_sbm_random_graph#
- undirected_sbm_random_graph(sizes, probabilities, loops, /, seed=None)#
Return an undirected graph from the stochastic block model.
The stochastic block model is a generalization of the \(G(n,p)\) random graph (see
undirected_gnp_random_graph()). The connection probability of nodesuandvdepends on their block (or community) and is given byprobabilities[blocks[u]][blocks[v]], whereblocks[u]is the block membership of nodeu. The number of nodes and the number of blocks are inferred fromsizes.This algorithm has a time complexity of \(O(n^2)\) for \(n\) nodes.
Arguments:
- Parameters:
sizes (list[int]) – Number of nodes in each block.
probabilities (np.ndarray) – Symmetric B x B array that contains the connection probability between nodes of different blocks.
loops (bool) – Determines whether the graph can have loops or not.
seed (int) – An optional seed to use for the random number generator.
- Returns:
A PyGraph object
- Return type: