knit_graphs.artin_wale_braids.Wale_Braid_Word module

Module containing the Wale Braid Word Class.

This module provides the Wale_Braid_Word class which represents a single step in a braid operation, describing how loops cross over each other within a course of knitting.

class Wale_Braid_Word(loops, crossings)[source]

Bases: object

A representation of loop crossings over a set of loops in a common course.

This class represents a single braid word in the mathematical sense, describing how a set of loops cross over or under each other within a horizontal course. Each braid word can be inverted and applied to determine the new ordering of loops after the crossing operations.

loops

The ordered list of loops that participate in this braid word.

Type:

list[Loop]

crossings

A mapping from loop indices to their crossing directions, where each key represents the index of a loop that crosses with the loop at index+1.

Type:

dict[int, Crossing_Direction]

Parameters:
__init__(loops, crossings)[source]

Initialize a wale braid word with the specified loops and crossing operations.

Parameters:
  • loops (list[Loop]) – The ordered list of loops that participate in this braid word.

  • crossings (dict[int, Crossing_Direction]) – A dictionary mapping loop indices to crossing directions.

  • direction. (Each index-key indicates that the loop at that index crosses with the loop at index+1 in the specified)

new_loop_order()[source]

Calculate the new ordering of loops after applying all crossing operations.

This method applies all the crossing operations defined in this braid word to determine the final ordering of loops. Crossings are applied from right to left (highest index to lowest) to maintain proper braid semantics.

Returns:

The list of loops in their new order after all crossing operations have been applied.

Return type:

list[Loop]

__invert__()[source]

Create the inverse braid word that undoes the operations of this braid word.

The inverse braid word uses the new loop order as its starting configuration and inverts all crossing directions to reverse the effect of the original braid word.

Returns:

A new braid word that represents the inverse operation of this braid word.

Return type:

Wale_Braid_Word

__eq__(other)[source]

Check equality with another wale braid word.

Two braid words are equal if they have the same loops in the same order and the same crossing operations at the same indices.

Parameters:

other (Wale_Braid_Word) – The other braid word to compare with.

Returns:

True if both braid words have identical loops, loop ordering, and crossing operations, False otherwise.

Return type:

bool

is_inversion(other)[source]

Check if another braid word is the inverse of this braid word.

Parameters:

other (Wale_Braid_Word) – The other braid word to compare against for inversion relationship.

Returns:

True if the other braid word is equal to the inverse of this braid word, False otherwise.

Return type:

bool

__len__()[source]

Get the number of loops in this braid word.

Returns:

The total number of loops participating in this braid word.

Return type:

int