graph_tool.generation.solve_sbm_fugacities(b, ers, out_degs=None, in_degs=None, multigraph=False, self_loops=False, epsilon=1e-08, iter_solve=True, max_iter=0, min_args={}, root_args={}, verbose=False)[source]#

Obtain SBM fugacities, given expected degrees and edge counts between groups.

biterable or numpy.ndarray

Group membership for each node.

erstwo-dimensional numpy.ndarray or scipy.sparse.spmatrix

Matrix with expected edge counts between groups. The value ers[r,s] corresponds to the average number of edges between groups r and s (or twice the average number if r == s and the graph is undirected).

out_degsiterable or numpy.ndarray

Expected out-degree for each node.

in_degsiterable or numpy.ndarray (optional, default: None)

Expected in-degree for each node. If not given, the graph is assumed to be undirected.

multigraphbool (optional, default: False)

Whether parallel edges are allowed.

self_loopsbool (optional, default: False)

Whether self-loops are allowed.

epsilonfloat (optional, default: 1e-8)

Whether self-loops are allowed.

iter_solvebool (optional, default: True)

Solve the system by simple iteration, not gradient-based root-solving. Relevant only if multigraph == False, otherwise iter_solve = True is always assumed.

max_iterint (optional, default: 0)

If non-zero, this will limit the maximum number of iterations.

min_args{} (optional, default: {})

Options to be passed to scipy.optimize.minimize(). Only relevant if iter_solve=False.

root_args{} (optional, default: {})

Options to be passed to scipy.optimize.root(). Only relevant if iter_solve=False.

verbosebool (optional, default: False)

If True, verbose information will be displayed.


Edge count fugacities.


Node out-degree fugacities.


Node in-degree fugacities. Only returned if in_degs is not None.

See also


Generate maximum-entropy SBM graphs


For simple directed graphs, the fugacities obey the following self-consistency equations:

\[\begin{split}\theta^+_i &= \frac{k^+_i}{\sum_{j\ne i}\frac{\theta^-_j\mu_{b_i,b_j}}{1+\theta^+_i\theta^-_j\mu_{b_i,b_j}}}\\ \theta^-_i &= \frac{k^-_i}{\sum_{j\ne i}\frac{\theta^+_j\mu_{b_j,b_i}}{1+\theta^+_i\theta^-_j\mu_{b_j,b_i}}}\\ \mu_{rs} &= \frac{e_{rs}}{\sum_{i\ne j}\delta_{b_i,r}\delta_{b_j,s}\frac{\theta^+_i\theta^-_j}{1+\theta^+_i\theta^-_j\mu_{r,s}}}\end{split}\]

For directed multigraphs, we have instead:

\[\begin{split}\theta^+_i &= \frac{k^+_i}{\sum_{j\ne i}\frac{\theta^-_j\mu_{b_i,b_j}}{1-\theta^+_i\theta^-_j\mu_{b_i,b_j}}}\\ \theta^-_i &= \frac{k^-_i}{\sum_{j\ne i}\frac{\theta^+_j\mu_{b_j,b_i}}{1-\theta^+_i\theta^-_j\mu_{b_j,b_i}}}\\ \mu_{rs} &= \frac{e_{rs}}{\sum_{i\ne j}\delta_{b_i,r}\delta_{b_j,s}\frac{\theta^+_i\theta^-_j}{1-\theta^+_i\theta^-_j\mu_{r,s}}}\end{split}\]

For undirected graphs, we have the above equations with \(\theta^+_i=\theta^-_i=\theta_i\), and \(\mu_{rs} = \mu_{sr}\).



Tiago P. Peixoto, “Latent Poisson models for networks with heterogeneous density”, Phys. Rev. E 102 012309 (2020) DOI: 10.1103/PhysRevE.102.012309 [sci-hub, @tor], arXiv: 2002.07803