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 nodes u and v depends on their block (or community) and is given by probabilities[blocks[u]][blocks[v]], where blocks[u] is the block membership of node u. The number of nodes and the number of blocks are inferred from sizes.

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:

PyDiGraph