graph_tool.inference.EMBlockState#
- class graph_tool.inference.EMBlockState(g, B, init_state=None)[source]#
Bases:
objectThe parametric, undirected stochastic block model state of a given graph.
- Parameters:
- g
Graph Graph to be modelled.
- B
int Number of blocks (or vertex groups).
- init_state
BlockState(optional, default:None) Optional block state used for initialization.
- g
Notes
This class is intended to be used with
em_infer()to perform expectation maximization with belief propagation. See [decelle_asymptotic_2011] for more details.References
[decelle_asymptotic_2011]Aurelien Decelle, Florent Krzakala, Cristopher Moore, and Lenka Zdeborová, “Asymptotic analysis of the stochastic block model for modular networks and its algorithmic applications”, Phys. Rev. E 84, 066106 (2011), DOI: 10.1103/PhysRevE.84.066106 [sci-hub, @tor], arXiv: 1109.3041
Methods
draw(**kwargs)Convenience wrapper to
graph_draw()that draws the state of the graph as colors on the vertices and edges.e_iter([max_iter, epsilon, verbose])Perform 'expectation' iterations, using belief propagation, where the vertex marginals and edge messages are updated, until convergence according to
epsilonor the maximum number of iterations given bymax_iter.get_MAP()Return the maximum a posteriori (MAP) estimate of the node partition.
get_ak()Return the model's average degree.
get_fe()Return the Bethe free energy.
Return the group sizes.
Return probability matrix.
Return the vertex marginals.
learn([epsilon])Perform 'maximization' iterations until convergence according to
epsilon.m_iter()Perform a single 'maximization' iteration, where the group sizes and connection probability matrix are updated.
- draw(**kwargs)[source]#
Convenience wrapper to
graph_draw()that draws the state of the graph as colors on the vertices and edges.
- e_iter(max_iter=1000, epsilon=0.001, verbose=False)[source]#
Perform ‘expectation’ iterations, using belief propagation, where the vertex marginals and edge messages are updated, until convergence according to
epsilonor the maximum number of iterations given bymax_iter. Ifverbose == True, convergence information is displayed.The last update delta is returned.