Hi everyone.
I just wanted to ask if it would be possible to parallelize this piece of code, ive tried to do it as its said in the documentation but it does not seem to be working

gt.mcmc_equilibrate(state, wait=100, mcmc_args=dict(niter=10), verbose=True)  # initial equilibration of MCMC (that is always performed in the tutorial)
    print(f'{network_file[0]} module refinement one carried out')
    # collect nested partitions
    bs = [] # recalling the module partitions at each iteration
    h = [np.zeros(g.num_vertices() + 1) for s in state.get_levels()] # recall the distribution of the number of modules throughout the whole equilibration process
    def collect_data(s):
        for l, sl in enumerate(s.get_levels()):
            B = sl.get_nonempty_B()
            h[l][B] += 1
    gt.mcmc_equilibrate(state, force_niter=1000, mcmc_args=dict(niter=10),
    print(f'{network_file[0]} module refinement two carried out')
    pmode = gt.PartitionModeState(bs, nested=True, converge=True)

thankyou for the response!


If you expect any kind of detailed feedback, you need to provide a minimal working example of what you are trying to do. The code fragment you sent isn’t even even property indented, and is not complete.

In any case, since the code does not include any loops, it’s unclear what you are trying to parallelize.

The internal MCMC loop itself cannot be parallelized, since the algorithm is serial.