cayleypy.CayleyGraphDef

class cayleypy.CayleyGraphDef[source]

Mathematical definition of a CayleyGraph.

__init__(generators_type: GeneratorType, generators_permutations: list[list[int]], generators_matrices: list[MatrixGenerator], generator_names: list[str], central_state: list[int], name: str) None

Methods

__init__(generators_type, ...)

create(generators[, generator_names, ...])

Creates Cayley Graph definition (when generators are permutations).

for_matrix_group(*, generators[, ...])

Creates Cayley Graph definition (when generators are matrices).

is_matrix_group()

Whether generators in this graph are matrices.

is_permutation_group()

Whether generators in this graph are permutations.

make_inverse_closed()

Makes generators inverse-closed, adding extra generators when necessary.

normalize_central_state(central_state)

path_to_string(path[, delimiter])

revert_path(path)

Given path A->B, returns path B->A.

with_central_state(central_state)

with_inverted_generators()

Returns the same graph where generators are replaced with inverses (in the same order).

with_name(name)

Attributes

decoded_state_shape

Shape of state when presented in decoded (human-readable) format.

generators

generators_inverse_closed

Whether for each generator its inverse is also a generator.

generators_inverse_map

Maps generators to their inverses.

n_generators

state_size

generators_type

generators_permutations

generators_matrices

generator_names

central_state

name

static create(generators: list[list[int]] | Tensor | ndarray, generator_names: list[str] | None = None, central_state: Tensor | ndarray | list | None = None, name: str = '')[source]

Creates Cayley Graph definition (when generators are permutations).

Parameters:
  • generators – List of generating permutations of size n.

  • generator_names – Names of the generators (optional).

  • central_state – List of n numbers between 0 and n-1, the central state. If None, defaults to the identity permutation of size n.

  • name – Name of this graph.

property decoded_state_shape: tuple[int, ...]

Shape of state when presented in decoded (human-readable) format.

static for_matrix_group(*, generators: list[MatrixGenerator], generator_names: list[str] | None = None, central_state: Tensor | ndarray | list | None = None, name: str = '')[source]

Creates Cayley Graph definition (when generators are matrices).

Parameters:
  • generators – List of generating n*n matrices.

  • generator_names – Names of the generators (optional).

  • central_state – the central state (n*m matrix). Defaults to the n*n identity matrix.

  • name – Name of this graph.

property generators_inverse_closed: bool

Whether for each generator its inverse is also a generator.

property generators_inverse_map: list[int] | None

Maps generators to their inverses. Returns None if generators are not inverse-closed.

is_matrix_group()[source]

Whether generators in this graph are matrices.

is_permutation_group()[source]

Whether generators in this graph are permutations.

make_inverse_closed() CayleyGraphDef[source]

Makes generators inverse-closed, adding extra generators when necessary.

If generators are already inverse-closed, returns self. Otherwise, for each generator that does not have its inverse in the set of generators, adds an inverse generator to the set.

revert_path(path: list[int]) list[int][source]

Given path A->B, returns path B->A. Only for inverse-closed generators.

with_inverted_generators() CayleyGraphDef[source]

Returns the same graph where generators are replaced with inverses (in the same order).

This is needed for restoring path in the Beam Search algorithm. Note that even when generators are self-inverse, this will be a different graph because order of generators changes. For example, LRX generators turn into RLX generators.