Negative labels in ModeClusterState of nested partitions

Hi Prof. Peixoto,

My graph tool version is 2.59
OS is linux ubuntu 22

ModeClusterState results in some negative labels in nested partitions.
How to resolve this problem?

My minimal working code is:

import numpy as np 
import pickle 
import graph_tool.all as gt 

gt.seed_rng(100)
np.random.seed(100)

with open(f'bs.pkl', 'rb') as f:
    bs = pickle.load(f)

pmode = gt.ModeClusterState(bs, nested=True)
gt.mcmc_equilibrate(pmode, wait=1, mcmc_args=dict(niter=1, beta=np.inf))

print(pmode.bs)

Uploading the necessary partitions, bs:
bs.pkl (524.1 KB)

Uploading the output of my code, pmode.bs:
pmode_bs.txt (522.6 KB)

As we can see, some labels are -1.
Please suggest some solution.

Many thanks,
Govinda

This is totally normal.

A value of -1 means that a given group does not have an assignment in the layer above, since it’s empty in the layer below.

Thank you!

Now when I create a NestedBlockState afresh, I get the following error:

import numpy as np 
import pickle 
import graph_tool.all as gt 

gt.seed_rng(100)
np.random.seed(100)

with open(f'bs.pkl', 'rb') as f:
    bs = pickle.load(f)

with open(f'graph.pkl', 'rb') as f:
    g = pickle.load(f)
    
pmode = gt.ModeClusterState(bs, nested=True)
gt.mcmc_equilibrate(pmode, wait=1, mcmc_args=dict(niter=1, beta=np.inf))

state = gt.NestedBlockState(g, bs=pmode.bs[0])

ERROR:

TypeError: _vt_copy() got an unexpected keyword argument 'value_type'

Is this expected?

This should be instead:

bs = nested_partition_clear_null(pmode.bs[0])
state = gt.NestedBlockState(g, bs=[g.new_vp("int", val=bs[0])] + bs[1:])
1 Like