<jupyter_start><jupyter_text>Finding all the solutions for a small graph<jupyter_code>with Timer(f"Generate {n} points"):
    from koala.pointsets import generate_random
    points = generate_random(min(n, 20), rng = default_rng(SEED))

#lattice
with Timer(f"Make dual graph of {n} points"):
    g = generate_lattice(points)  

fixed = enumerate(clockwise_edges_about(vertex_i = 0, g=g))

with Timer(f"Get one edge coloring"):
    solveable, solution = edge_color(g, n_colors = 3, fixed = fixed)

with Timer(f"Get all unconstrained edge colorings"):
    solveable, unconstrained_solutions = edge_color(g, n_colors = 3, all_solutions = True)
    
with Timer(f"Get all constrained edge colorings"):
    fixed = enumerate(clockwise_edges_about(vertex_i = 0, g=g))
    solveable, constrained_solutions = edge_color(g, n_colors = 3, fixed = fixed, all_solutions = True)

if solveable:
    degeneracy = unconstrained_solutions.shape[0] / constrained_solutions.shape[0]
    assert(degeneracy == 6.0)
    print(f"There are {constrained_solutions.shape[0]} solutions and the degeneracy is {degeneracy}")
from math import ceil
def plot_all_solutions(g):
    fixed = enumerate(clockwise_edges_about(vertex_i = 0, g=g))
    solveable, solutions = edge_color(g, n_colors = 3, fixed = fixed, all_solutions = True)
    if not solveable: return
    
    N = solutions.shape[0]
    size = 3
    cols, rows = min(size, N), ceil(N/size)
    fig, axes = plt.subplots(ncols = cols, nrows = rows, figsize = (5*cols, 5*rows), squeeze = False)
    print(f'There are {N} solutions')
    for ax, solution in zip(axes.flatten(), solutions):
#         plot_degeneracy_breaking(0, g, ax = ax)
        plot_lattice(g, edge_labels = solution, ax = ax)

points = generate_random(min(n,8), rng = default_rng(SEED))
g = generate_lattice(points)
plot_all_solutions(g)
from math import ceil
def plot_changes(g):
    fixed = enumerate(clockwise_edges_about(vertex_i = 0, g=g))
    solveable, solutions = edge_color(g, n_colors = 3, fixed = fixed, n_solutions = 9)
    if not solveable: return
    solutions = np.where(solutions != solutions[0,None], solutions, 3)
    
    N = solutions.shape[0]
    size = 3
    cols, rows = min(size, N), ceil(N/size)
    fig, axes = plt.subplots(ncols = cols, nrows = rows, figsize = (5*cols, 5*rows), squeeze = False)
    print(f'There are {N} solutions')
    for ax, solution in zip(axes.flatten(), solutions):
#         plot_degeneracy_breaking(0, g, ax = ax)
        plot_lattice(g, edge_labels = solution, ax = ax)


points = generate_random(n, rng = default_rng(SEED))
g = generate_lattice(points)
plot_changes(g)
n_points = n
points = generate_random(n_points, rng = default_rng(SEED))
g = generate_lattice(points)
with Timer(f"Get one edge coloring"):
    solveable, solution = edge_color(g, n_colors = 3, fixed = fixed)

with Timer(f"Get 100 edge colorings"):
    fixed = enumerate(clockwise_edges_about(vertex_i = 0, g=g))
    solveable, solutions = edge_color(g, n_colors = 3, fixed = fixed, n_solutions = 100)
    
with Timer(f"Get all edge colorings"):
    fixed = enumerate(clockwise_edges_about(vertex_i = 0, g=g))
    solveable, solutions = edge_color(g, n_colors = 3, fixed = fixed, all_solutions = True)

if solveable: print(f"There are {solutions.shape[0]} total solutions for this graph with {n_points} points")<jupyter_output>Get one edge coloring completed in 0.01 seconds
Get 100 edge colorings completed in 0.02 seconds
Get all edge colorings completed in 0.50 seconds
There are 1413 total solutions for this graph with 30 points
{'fraction_non_alphanumeric': 0.11261261261261261, 'fraction_numerical': 0.016891891891891893, 'mean_word_length': 4.534267912772585, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '261091', 'license': 'MIT', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1205, 'n_words': 340, 'path': 'examples/lattice_generation.ipynb', 'repo_name': 'Imperial-CMTH/koala', 'size': '3552'}