fix(hn): fix Golomb graph construction + EVAL NoneType formatting

1. Golomb graph: scale pentagon to side=1 (radius=1/(2*sin(π/5)))
   Previous construction had 0 edges (vertices not at unit distance)
2. Fix f-string NoneType crash in EVAL writer when welch_wynn is None
This commit is contained in:
openresearch 2026-07-04 08:47:32 +00:00
parent 4bf4fa8afc
commit 07adc46931

View file

@ -47,26 +47,26 @@ def moser_spindle():
return adj, pts, "Moser spindle", 4
def golomb_graph():
"""Golomb graph: 10 vertices, χ=4, unit-distance graph.
"""Golomb graph: 10 vertices, unit-distance graph.
Constructed from two 5-cycles sharing a vertex, with unit distances.
Based on Golomb's construction (1970).
Two regular pentagons with side length 1, sharing one vertex.
Pentagon side = 1 radius = 1/(2*sin(π/5)).
"""
# Golomb's 10-vertex graph: two pentagons connected at one vertex
# Each pentagon has side length 1 (unit distance)
r = 1.0 / (2 * math.sin(math.pi / 5)) # circumradius for side=1
pts = []
# First pentagon centered at origin
# First pentagon, vertex 0 at origin
for i in range(5):
angle = 2 * math.pi * i / 5
pts.append((math.cos(angle), math.sin(angle)))
# Second pentagon, rotated and translated
# The connection vertex is at (1, 0) — shared
# Second pentagon centered at (2, 0), rotated by π/5
cx, cy = 2.0, 0.0
pts.append((r * math.cos(angle) - r, r * math.sin(angle)))
# Second pentagon, sharing vertex 0, rotated by π/5
for i in range(5):
angle = 2 * math.pi * i / 5 + math.pi / 5
pts.append((cx + math.cos(angle), cy + math.sin(angle)))
# Shift so vertex 0 aligns with first pentagon's vertex 0
dx = r * math.cos(math.pi / 5) - r
dy = r * math.sin(math.pi / 5)
pts.append((r * math.cos(angle) - r - dx, r * math.sin(angle) - dy))
pts = hn.remove_duplicates(pts)
adj = hn.build_adjacency(pts)
n_v = len(pts)
n_e = sum(len(a) for a in adj) // 2
@ -357,11 +357,13 @@ def write_eval(results):
"|-------|---|---|-------|------|---------|--------|------------|------|---------|-----|",
]
for g in results["graphs"]:
ww = g['welch_wynn']
ww_str = f"{ww:.4f}" if ww is not None else "N/A"
lines.append(
f"| {g['description']} | {g['n_vertices']} | {g['n_edges']} | "
f"{g['lambda_max']:.4f} | {g['lambda_min']:.4f} | "
f"{g['hoffman_bound']:.4f} | {g['chi_hoffman']} | "
f"{g['welch_wynn']:.4f if g['welch_wynn'] else 'N/A'} | "
f"{g['hoffman_bound']:.4f} if g['hoffman_bound'] is not None else 'inf' | "
f"{g['chi_hoffman']} | {ww_str} | "
f"{g['chi_welch_wynn']} | {g['chi_known']} | {g['gap']} |"
)