# graph_tool.inference.align_nested_partition_labels#

graph_tool.inference.align_nested_partition_labels(x, y)[source]#

Returns a copy of nested partition x, with the group labels aligned as to maximize the overlap with y.

Parameters:
xiterable of iterables of int values

Partition.

Returns:
ylist of numpy.ndarray

Nested partition with aligned labels.

Notes

This algorithm runs in time $$O[\sum_l N_l + (B_x^l+B_y^l)E_m^l]$$ where $$B_x^l$$ and $$B_y^l$$ are the number of labels in partitions $$\bar{\boldsymbol x}$$ and $$\bar{\boldsymbol y}$$ at level $$l$$, respectively, and $$E_m^l \le B_x^lB_y^l$$ is the number of nonzero entries in the contingency table between both partitions.

Examples

>>> x = [[0, 2, 2, 1, 1, 1, 2, 3, 2], [1, 0, 1, 0], [0,0]]
>>> y = gt.shuffle_nested_partition_labels(x)
>>> print(y)
[array([0, 3, 3, 2, 2, 2, 3, 1, 3], dtype=int32), array([1, 0, 0, 1], dtype=int32), array([0, 0], dtype=int32)]
>>> gt.align_nested_partition_labels(y, x)
[array([0, 2, 2, 1, 1, 1, 2, 3, 2], dtype=int32), array([1, 0, 1, 0], dtype=int32), array([0, 0], dtype=int32)]