Note
This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.
rustworkx.directed_sbm_random_graph#
- directed_sbm_random_graph(sizes, probabilities, loops, /, seed=None)#
Return a directed graph from the stochastic block model.
The stochastic block model is a generalization of the \(G(n,p)\) random graph (see
directed_gnp_random_graph()
). The connection probability of nodesu
andv
depends 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) – 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 PyDiGraph object
- Return type: