Visualizing multiple memberhips in OverlapBlockState

Hi,

I have been attempting to visualize the inferred partition for the overlapping SBM using half-edge labels as pie-chart colors for nodes. Do you know how I can achieve this with graph-tool?

I have tried retrieving block memberships and using them as an argument for pie-chart proportions. However, I must be making a mistake, because visualization does not look good.

Best,
Stepan

state = OverlapBlockState(g, nested = True)
dS, nmoves = 0, 0
for i in range(100):
    ret = state.multiflip_mcmc_sweep(niter=10)
    dS += ret[0]
    nmoves += ret[1]
be = state.get_edge_blocks()
bm = g.new_vp("vector<int>", val=[0] * state.get_B())
for e in g.edges():
     u, v = e
     u, v = sorted((u, v))
     r, s = be[e]
     bm[u][r] += 1
     bm[v][s] += 1
state.draw(vertex_shape="pie", vertex_pie_fractions = bm, output="overlapSBM.pdf")

overlapSBM.pdf (623.8 KB)

Just calling state.draw() should do this for you automatically.