graph_tool.inference.EMBlockState#

class graph_tool.inference.EMBlockState(g, B, init_state=None)[source]#

Bases: object

The parametric, undirected stochastic block model state of a given graph.

Parameters:
gGraph

Graph to be modelled.

Bint

Number of blocks (or vertex groups).

init_stateBlockState (optional, default: None)

Optional block state used for initialization.

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 epsilon or the maximum number of iterations given by max_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.

get_group_sizes()

Return the group sizes.

get_matrix()

Return probability matrix.

get_vertex_marginals()

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 epsilon or the maximum number of iterations given by max_iter. If verbose == True, convergence information is displayed.

The last update delta is returned.

get_MAP()[source]#

Return the maximum a posteriori (MAP) estimate of the node partition.

get_ak()[source]#

Return the model’s average degree.

get_fe()[source]#

Return the Bethe free energy.

get_group_sizes()[source]#

Return the group sizes.

get_matrix()[source]#

Return probability matrix.

get_vertex_marginals()[source]#

Return the vertex marginals.

learn(epsilon=0.001)[source]#

Perform ‘maximization’ iterations until convergence according to epsilon.

The last update delta is returned.

m_iter()[source]#

Perform a single ‘maximization’ iteration, where the group sizes and connection probability matrix are updated.

The update delta is returned.