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]) 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.

normalize_central_state(central_state)

with_central_state(central_state)

with_inverted_generators()

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

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.

n_generators

state_size

generators_type

generators_permutations

generators_matrices

generator_names

central_state

static create(generators: list[list[int]] | Tensor | ndarray, generator_names: list[str] | None = None, central_state: list[int] | Tensor | ndarray | str | None = None)[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.

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: ndarray | list[list[int]] | list[int] | None = None)[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.

property generators_inverse_closed: bool

Whether for each generator its inverse is also a generator.

is_matrix_group()[source]

Whether generators in this graph are matrices.

is_permutation_group()[source]

Whether generators in this graph are permutations.

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.