knit_graphs.artin_wale_braids.Loop_Braid_Graph module
Module containing the Loop Braid Graph class.
This module provides the Loop_Braid_Graph class which tracks crossing relationships between loops in cable knitting patterns using a directed graph structure.
- class Loop_Braid_Graph[source]
Bases:
object
A graph structure that tracks crossing braid edges between loops in cable patterns.
This class maintains a directed graph where nodes are loops and edges represent cable crossings between those loops. It provides methods to add crossings, query crossing relationships, and determine which loops cross with a given loop.
- loop_crossing_graph
A NetworkX directed graph storing loop crossing relationships with crossing direction attributes.
- Type:
DiGraph
- add_crossing(left_loop, right_loop, crossing_direction)[source]
Add a crossing edge between two loops with the specified crossing direction.
- Parameters:
left_loop (Loop) – The loop on the left side of the crossing.
right_loop (Loop) – The loop on the right side of the crossing.
crossing_direction (Crossing_Direction) – The direction of the crossing (over, under, or none) between the loops.
- Return type:
- remove_loop(loop)[source]
Removes any crossings that involve the given loop. :type loop:
Loop
:param loop: The loop to remove. :type loop: Loop- Return type:
- left_crossing_loops(left_loop)[source]
Get all loops that cross with the given loop when it is on the left side.
- right_crossing_loops(right_loop)[source]
Get all loops that cross with the given loop when it is on the right side.
- get_crossing(left_loop, right_loop)[source]
Get the crossing direction between two loops, creating a no-cross edge if none exists.
If no edge exists between the loops, this method automatically adds a no-crossing edge to maintain consistency in the graph structure.
- Parameters:
- Returns:
The crossing direction between the left and right loop. Defaults to No_Cross if no explicit crossing was previously defined.
- Return type: