[graph-tool] projecting vertex marginals to hierarchy levels

Davide Cittaro cittaro.davide at gmail.com
Wed Jan 15 18:01:35 CET 2020

Hi again, 
I'm following the cookbook and I'm collecting vertex marginals during mcmc_equilibrate, so

pv = [None] * len(state.get_levels())
def collect_marginals(s):
    global pv
    pv = [sl.collect_vertex_marginals(pv[l]) for l, sl in enumerate(s.get_levels())]

gt.mcmc_equilibrate(state, force_niter=1000, mcmc_args=dict(niter=10), wait=wait,
    nbreaks=nbreaks, epsilon=epsilon, callback=collect_marginals

After this is done, every element of pv will be, basically, a list of arrays with as many elements as many vertexs are at specific level, each with the counts for memberships.
In fact, when I need to assign groups to the original vertexs to a blockstate at level L > 0 (say, level 2) I can use

state.project_partition(2, 0)

the vertex map will contain as many elements as the number of vertex of my graph, each labeled according to the blocks at level 2 of the hierarchy. 
I cannot find a smart way to project the marginals I've collected, would it be sufficient to sum numbers for pv[0] following the hierarchy (that is, summing counts for all groups at level 0 which are included in the same group at level 2)? 



More information about the graph-tool mailing list