Hi Prof. Peixoto,
I’m running into an alignment issue when using PartitionModeState()
in graph-tool
;
v2.92 on Ubuntu 22, Python 3.9.
I’m attempting to align an ensemble of partitions that consists of two pre-aligned subsets (i.e., partitions within each subset are already label-consistent). However, PartitionModeState
does not seem to resolve the alignment across the two subsets, no matter the variation of arguments I try.
MWE:
import numpy as np
import dill as pickle
import graph_tool.all as gt
# load partitions
with open('bs_1.pkl', 'rb') as f:
[bs1] = pickle.load(f)
print(f'len of bs1: {len(bs1)}')
with open('bs_2.pkl', 'rb') as f:
[bs2] = pickle.load(f)
print(f'len of bs2: {len(bs2)}')
bs = bs1 + bs2
# align partitions
pmode = gt.PartitionModeState(bs, relabel=True, nested=False, converge=False)
delta = 1
while np.abs(delta) > 1e-8:
delta = pmode.replace_partitions()
print(delta)
bs_aligned = [v for k, v in sorted(pmode.get_partitions().items())]
# Alignment checks
# 1. Within bs1
x, y = bs_aligned[23], bs_aligned[0]
print(gt.align_partition_labels(x, y) - x)
# 2. Within bs2
x, y = bs_aligned[89], bs_aligned[67]
print(gt.align_partition_labels(x, y) - x)
# 3. Across bs1 and bs2
x, y = bs_aligned[89], bs_aligned[0]
print(gt.align_partition_labels(x, y) - x)
I check whether the partitions are aligned using the gt.align_partition_labels(x, y)
function. x
is from bs1
, and y
from bs2
. If the partitions are aligned across the sets, then this function should return the same x
.
As expected, partitions within each set remain aligned. However, partitions across the two sets remain unaligned, even after convergence of pmode
.
Is there anything additional I should incorporate to force PartitionModeState
to resolve alignment across these subgroups?