The Bipartition class

Class for representing bipartitions.

A bipartition is a partition of the set \(\{0, ..., 2n - 1\}\) for some non-negative integer \(n\); see the Semigroups package for GAP documentation for more details.

Contents

Bipartition

Class for representing bipartitions.

Bipartition.copy(…)

Copy a Bipartition object.

Bipartition.degree(…)

Return the degree of the bipartition.

Bipartition.is_transverse_block(…)

Check if a block is a transverse block.

Bipartition.iterator(…)

Return an iterator yielding the indices of the blocks.

Bipartition.left_blocks(…)

Returns a copy of the left blocks of a bipartition.

Bipartition.lookup(…)

Returns the transverse blocks lookup.

Bipartition.number_of_blocks(…)

Return the number of blocks in a Bipartition.

Bipartition.number_of_left_blocks(…)

Return the number of blocks containing a positive integer.

Bipartition.number_of_right_blocks(…)

Return the number of blocks containing a negative integer.

Bipartition.one(…)

Return the identity bipartition of given degree.

Bipartition.rank(…)

Return the number of transverse blocks.

Bipartition.right_blocks(…)

Returns a copy of the right blocks of a bipartition.

Full API

class Bipartition
__init__(*args, **kwargs)

Overloaded function.

__init__(self: Bipartition, blocks: list[list[int]]) None

Construct a bipartition from a partition.

The items in blocks should be:

  • duplicate-free;

  • pairwise disjoint; and

  • partition the set \(\{-n, \ldots, -1, 1, \ldots, n\}\) for some positive integer \(n\).

Parameters:

blocks (list[list[int]]) – the underlying partition.

Raises:

LibsemigroupsError – if any of the conditions above is not met.

__init__(self: Bipartition, lookup: list[int]) None

Construct a bipartition from a blocks lookup.

The parameter lookup:

  • is copied;

  • must have length \(2n\) for some positive integer \(n\);

  • consist of non-negative integers; and

  • have the property that if \(i\), \(i > 0\) occurs in lookup, then \(i - 1\) occurs earlier in lookup. The value of blocks[i] should represent the index of the block containing i.

For example, if lookup is [0, 1, 1, 2, 1, 1, 3, 1, 1, 4, 5, 6], then the above conditions are satisfied, but if lookup is [1, 0, 1, 10] then they are not.

Parameters:

lookup (list[int]) – a lookup for the blocks of the bipartition being constructed.

Raises:

LibsemigroupsError – if any of the conditions above is not met.

copy(self: Bipartition) Bipartition

Copy a Bipartition object.

Returns:

A copy.

Return type:

Bipartition

degree(self: Bipartition) int

Return the degree of the bipartition.

A bipartition is of degree \(n\) if it is a partition of \(\{0, \ldots, 2n - 1\}\).

Returns:

The degree.

Return type:

int

is_transverse_block(self: Bipartition, index: int) bool

Check if a block is a transverse block.

A block of a biparition is transverse if it contains integers less than and greater than \(n\), which is the degree of the bipartition.

Parameters:

index (int) – the index of a block

Returns:

Whether or not the given block is transverse.

Return type:

bool

Raises:

LibsemigroupsError – if index is not in the range from 0 to number_of_left_blocks.

Complexity:

At worst \(O(n)\) where \(n\) is the degree().

iterator(self: Bipartition) collections.abc.Iterator[int]

Return an iterator yielding the indices of the blocks.

Returns:

An iterator yielding the indices of the blocks.

Return type:

collections.abc.Iterator[int]

Complexity:

Constant.

left_blocks(self: Bipartition) Blocks

Returns a copy of the left blocks of a bipartition.

The left blocks of a bipartition is the partition of \(\{0, \ldots, n - 1\}\) induced by the bipartition. This function returns a Blocks object representing this partition.

Returns:

A copy of the left blocks.

Return type:

Blocks

Complexity:

\(O(n)\) where \(n\) is degree().

lookup(self: Bipartition) list[bool]

Returns the transverse blocks lookup. The value in position i of the returned list is True if the block with index i is transverse and False if it is not transverse.

Returns:

The lookup for transvere blocks.

Return type:

list[bool]

Complexity:

Constant.

number_of_blocks(self: Bipartition) int

Return the number of blocks in a Bipartition. This function returns the number of parts in the partition that instances of this class represent.

Returns:

The number of blocks.

Return type:

int

Complexity:

At worst \(O(n)\) where \(n\) is the degree().

number_of_left_blocks(self: Bipartition) int

Return the number of blocks containing a positive integer. The left blocks of a bipartition is the partition of \(\{0, \ldots, n - 1\}\) induced by the bipartition. This member function returns the number of blocks in this partition.

Returns:

The number of left blocks.

Return type:

int

Complexity:

At worst \(O(n)\) where \(n\) is the degree().

number_of_right_blocks(self: Bipartition) int

Return the number of blocks containing a negative integer. The right blocks of a bipartition is the partition of \(\{n, \ldots, 2n - 1\}\) induced by the bipartition. This member function returns the number of blocks in this partition.

Returns:

The number of right blocks.

Return type:

int

Complexity:

At worst \(O(n)\) where \(n\) is the degree().

static one(self: Bipartition, n: int) Bipartition

Return the identity bipartition of given degree.

Returns the identity bipartition of degree n. The identity bipartition of degree \(n\) has blocks \(\{i, -i\}\) for all \(i\in \{0, \ldots, n - 1\}\). This member function returns a new identity bipartition of degree equal to n.

Parameters:

n (int) – the degree of the identity to be returned.

Returns:

A newly constructed Bipartition.

Return type:

Bipartition

rank(self: Bipartition) int

Return the number of transverse blocks. The rank of a bipartition is the number of blocks containing both positive and negative values, which are referred to as the transverse blocks.

Returns:

The number of transverse blocks.

Return type:

int

Complexity:

\(O(n)\) where \(n\) is degree().

right_blocks(self: Bipartition) Blocks

Returns a copy of the right blocks of a bipartition.

The right blocks of a bipartition is the partition of \(\{0, \ldots, n - 1\}\) induced by the bipartition. This function returns a Blocks object representing this partition.

Returns:

A copy of the right blocks.

Return type:

Blocks

Complexity:

\(O(n)\) where \(n\) is degree().