Add branching medial tire decomposition example

This commit is contained in:
2026-06-15 14:18:47 -04:00
parent f537db9758
commit 5829938ab0
4 changed files with 33 additions and 4 deletions
@@ -0,0 +1,19 @@
# Random medial tire decomposition 1
- vertices: 30
- edges: 84
- node connectivity: 5
- source vertex: 14
- tire-tree nodes: 4
- tire-tree edges: 3
| node | depth | faces | annular | up | down | bites | full medial tires |
|--:|--:|--:|--:|--:|--:|--:|--:|
| T0 | 2 | 23 | 23 | 10 | 13 | 0 | 1 |
| T0.0 | | | | 10 | 13 | - | `UDDUDUUDDUDUDUDUDDDUUDD` |
| T1 | 1 | 15 | 15 | 5 | 10 | 0 | 1 |
| T1.0 | | | | 5 | 10 | - | `UDDDUDDUDUDDDUD` |
| T2 | 3 | 8 | 5 | 11 | 0 | 0 | 1 |
| T2.0 | | | | 5 | 0 | - | `UUUUU` |
| T3 | 3 | 5 | 5 | 5 | 0 | 0 | 1 |
| T3.0 | | | | 5 | 0 | - | `UUUUU` |
@@ -450,10 +450,18 @@ def draw_case(out_dir: Path, graph_idx: int, g: nx.Graph, source: int):
def run(args: argparse.Namespace):
out_dir = Path(args.out_dir)
out_dir.mkdir(parents=True, exist_ok=True)
if args.graph6:
graphs = [nx.from_graph6_bytes(args.graph6.encode())]
if args.source is None:
raise ValueError("--source is required with --graph6")
sources = [args.source]
else:
graphs = sample_plantri_graphs(args.n, args.count, args.seed, args.scan_limit)
rng = random.Random(args.seed + 101)
for i, graph in enumerate(graphs, start=1):
source = rng.choice(list(graph.nodes()))
sources = [rng.choice(list(graph.nodes())) for graph in graphs]
for i, (graph, source) in enumerate(zip(graphs, sources), start=1):
png, pdf, node_count, tire_count = draw_case(out_dir, i, graph, source)
print(
f"case {i}: source={source}, connectivity={nx.node_connectivity(graph)}, "
@@ -469,6 +477,8 @@ def main():
parser.add_argument("--count", type=int, default=2)
parser.add_argument("--seed", type=int, default=20260615)
parser.add_argument("--scan-limit", type=int, default=500)
parser.add_argument("--graph6", help="draw this graph6 graph instead of sampling")
parser.add_argument("--source", type=int, help="source vertex for --graph6")
parser.add_argument(
"--out-dir",
default=str(PAPER_DIR / "experiments" / "random_medial_tire_decompositions"),