File size: 1,408 Bytes
77b193c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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()