"""Draw the walk-depth labelling and cut of a medial tire decomposition. Paper-graphics companion to ``run_medial_tire_cut_experiment.py``: it imports ``run_experiment`` from there, runs the pipeline on a random maximal planar graph, and emits a TikZ ``tikzpicture`` (walk-depth labels + cut slits) for each recognised full medial tire graph of the decomposition, using ``to_tikz`` from ``medial_tire_cut_labelling``. This script only renders; the experiment itself draws nothing. Run with the repo venv (networkx): ``.venv/bin/python``. Example: .venv/bin/python draw_medial_tire_cut.py -n 20 --seed 72 > panels.tex """ from __future__ import annotations import argparse import os import sys _HERE = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, _HERE) from run_medial_tire_cut_experiment import run_experiment # noqa: E402 from medial_tire_cut_labelling import to_tikz # noqa: E402 def tikz_panels(n: int, seed: int, scale: float = 1.6) -> tuple[dict, list[str]]: """Run the experiment and return ``(result, panels)``, one TikZ panel per recognised tread, each showing that tread's walk-depth labelling and cut.""" result = run_experiment(n=n, seed=seed) panels = [] for d in sorted(result["results"]): rec = result["results"][d] panels.append(to_tikz(rec["g"], depth=rec["depth"], cuts=rec["cuts"], entry_edge=rec["entry_edge"], scale=scale)) return result, panels def main() -> None: parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument("-n", type=int, default=20) parser.add_argument("--seed", type=int, default=72) parser.add_argument("--scale", type=float, default=1.6) args = parser.parse_args() result, panels = tikz_panels(args.n, args.seed, scale=args.scale) treads = sorted(result["results"]) print(f"% medial tire cut: n={args.n} seed={args.seed} " f"source={result['source']} recognised treads={treads}") if not panels: print("% (no recognised full medial tire graphs for this graph)") for d, panel in zip(treads, panels): g = result["results"][d]["g"] print(f"% --- tread {d}: |A(T)|={g.n} word={g.tooth_word} " f"bites={sorted(g.bites)} ---") print(panel) if __name__ == "__main__": main()