Download verify.py from aninokumar/ramsey52: direct link, hf CLI and curl.
- Browser
- Download file 1.41 kB
-
https://huggingface.co/aninokumar/ramsey52/resolve/main/verify.py
- Command line
-
hf download hf://aninokumar/ramsey52/verify.py
-
curl -L -o verify.py https://huggingface.co/aninokumar/ramsey52/resolve/main/verify.py
1.41 kB
| import json | |
| from itertools import combinations | |
| def verify_ramsey_coloring(): | |
| """Verify R(5,5,5) coloring with n=52 and 3 colors.""" | |
| # Load the cleaned verification data | |
| with open('ramsey_verification.json') as f: | |
| data = json.load(f) | |
| n, k, colors = data['n'], data['k'], data['num_colors'] | |
| assignment = data['assignment'] | |
| # Reconstruct edge coloring from assignment | |
| edges = [(i, j) for i in range(n) for j in range(i + 1, n)] | |
| coloring = {} | |
| for idx, (u, v) in enumerate(edges): | |
| for c in range(colors): | |
| if assignment[idx * colors + c] > 0.5: | |
| coloring[(u, v)] = c | |
| break | |
| # Verify all K5 cliques are not monochromatic | |
| total_cliques = 0 | |
| monochromatic_cliques = 0 | |
| for clique in combinations(range(n), k): | |
| clique_edges = [coloring[(u, v)] for u, v in combinations(clique, 2)] | |
| total_cliques += 1 | |
| if len(set(clique_edges)) == 1: # All edges same color | |
| monochromatic_cliques += 1 | |
| print(f"R({k},{k},{k}) verification results:") | |
| print(f"Total K{k} cliques: {total_cliques:,}") | |
| print(f"Monochromatic K{k} cliques: {monochromatic_cliques}") | |
| print(f"Valid coloring: {'Yes' if monochromatic_cliques == 0 else 'No'}") | |
| return monochromatic_cliques == 0 | |
| if __name__ == "__main__": | |
| verify_ramsey_coloring() |