Random graph with edge probabilities to make a multi-partite graph

Operating system version:
❯ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 23.10
Release: 23.10
Codename: mantic

Graph-tool version:
The version distributed by canonical in mantic

Problem description:
I am using this function for the edge probabilities between blocks in a random graph block model

def prob(a,b):
    return 0 if a==b else 1

I am expecting to see a graph where there are zero edges between members of the same block and only edges between members of different blocks, the latter as per the sampler for the degree distribution. The model is ‘block-degree’, I do pass the correct block membership as a list.

N=2000
blocks = choices(types[s],
                 cum_weights = list(accumulate(fracs[s])),
                 k = N)
gg, bm = gt.generation.random_graph(N,
                                    lambda ix,nb: sample_k(uc, funcs[s][types[s].index(nb)]),
                                    directed=False,
                                    model='blockmodel-degree',
                                    block_membership=blocks,
                                    edge_probs = prob,
                                    degree_block=False)

However, when looking a sample I observe that connections between nodes of the same block are in fact present. What am I doing wrong?

Regards,
Alex

There’s no such thing. Please be specific about the version that you are using.

You need to pass a sufficiently large value to the n_iter parameter, which defaults to 1.

To generate SBM graphs, I recommend using the generate_sbm() function instead.

The only info I have on the graph tool version is taken from the package details ubuntu provides:

Not sure where to find the exact details you would require.

Increasing n_iter to 1000 helps! Thank you very much. It does not prevent in group edges completely though.

According to the docs for generate_sbm() I need to give that function the number of connections between blocks. However I only know probabilities, not absolute counts. Did I misunderstand the docs?

The intent is to create a tri-partite graph that obeys a certain degree distribution. What I can do is to compute the average number of edges between groups by multiplying the probabilities taken from the degree distribution (which are block specific) by the block sizes. Would that be what you propose?

Alex

Clicking on that link tells me that the version is 2.57. This is all that needed to be said.

Exactly.