Preserving the degree-sequence while generating SBM

Hello Tiago,

I am trying to generate a stochastic block model but with the
degree-sequence preserved. I am fine even if the degree-distribution is
preserved instead of the exact sequence. I tried the following:

def prob(a, b):
    if a == b :
        return 0.999
    else:
        return 0.001

g, bm = gt.random_graph(N, lambda: 1 + np.random.poisson(5), model =
"blockmodel-degree", directed = False,
block_membership=np.random.randint(0, b, N), edge_probs = prob)

However, this generates an ER graph. What can I do to retain the
block-structure?

Thank you

attachment.html (912 Bytes)

I forgot to mention that 'b' in np.random.randint(0, b, N) is the number of
blocks.

Thank you

attachment.html (1.74 KB)

I believe this is a bug with the alias method used. Try with the option
"alias=False", and don't forget to use a large value of "n_iter".

I'll provide a fix in git soon.

Best,
Tiago

That worked! Thanks a lot.

Snehal

attachment.html (2.09 KB)