solve_sbm_fugacities#
- 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.
- Parameters:
- biterable or
numpy.ndarray
Group membership for each node.
- erstwo-dimensional
numpy.ndarray
orscipy.sparse.spmatrix
Matrix with expected edge counts between groups. The value
ers[r,s]
corresponds to the average number of edges between groupsr
ands
(or twice the average number ifr == 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.
- multigraph
bool
(optional, default:False
) Whether parallel edges are allowed.
- self_loops
bool
(optional, default:False
) Whether self-loops are allowed.
- epsilon
float
(optional, default:1e-8
) Whether self-loops are allowed.
- iter_solve
bool
(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_iter
int
(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 ifiter_solve=False
.- root_args
{}
(optional, default:{}
) Options to be passed to
scipy.optimize.root()
. Only relevant ifiter_solve=False
.- verbose
bool
(optional, default:False
) If
True
, verbose information will be displayed.
- biterable or
- Returns:
- mrs
scipy.sparse.spmatrix
Edge count fugacities.
- out_theta
numpy.ndarray
Node out-degree fugacities.
- in_theta
numpy.ndarray
Node in-degree fugacities. Only returned if
in_degs is not None
.
- mrs
See also
generate_maxent_sbm
Generate maximum-entropy SBM graphs
Notes
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}\).
References
[peixoto-latent-2020]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