***************************************************************************** * www.FindStat.org - The Combinatorial Statistic Finder * * * * Copyright (C) 2019 The FindStatCrew * * * * This information is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * ***************************************************************************** ----------------------------------------------------------------------------- Statistic identifier: St001330 ----------------------------------------------------------------------------- Collection: Graphs ----------------------------------------------------------------------------- Description: The hat guessing number of a graph. Suppose that each vertex of a graph corresponds to a player, wearing a hat whose color is arbitrarily chosen from a set of \$q\$ possible colors. Each player can see the hat colors of his neighbors, but not his own hat color. All of the players are asked to guess their own hat colors simultaneously, according to a predetermined guessing strategy and the hat colors they see, where no communication between them is allowed. The hat guessing number \$HG(G)\$ of a graph \$G\$ is the largest integer \$q\$ such that there exists a guessing strategy guaranteeing at least one correct guess for any hat assignment of \$q\$ possible colors. Because it suffices that a single player guesses correctly, the hat guessing number of a graph is the maximum of the hat guessing numbers of its connected components. ----------------------------------------------------------------------------- References: [1] Alon, N., Ben-Eliezer, O., Shangguan, C., Tamo, I. The hat guessing number of graphs [[arXiv:1812.09752]] ----------------------------------------------------------------------------- Code: @cached_function def get_hat_guessing(N): d = {} # complete graphs for n in range(1,N): G = graphs.CompleteGraph(n).canonical_label().copy(immutable=True) d[G] = n # trees, Butler for n in range(2,N): for G in graphs.trees(n): G = G.canonical_label().copy(immutable=True) d[G] = 2 # cycles, Szczechla for n in range(3,N): G = graphs.CycleGraph(n).canonical_label().copy(immutable=True) if n == 4 or n % 3 == 0: d[G] = 3 else: d[G] = 2 return d def statistic(G): """ Return the hat guessing number, or None. """ hat_guessing = get_hat_guessing(10) HG = 1 for H in G.connected_components_subgraphs(): hg = hat_guessing.get(H.canonical_label().copy(immutable=True), None) if hg is None: return HG = max(HG, hg) return HG ----------------------------------------------------------------------------- Statistic values: ([],1) => 1 ([],2) => 1 ([(0,1)],2) => 2 ([],3) => 1 ([(1,2)],3) => 2 ([(0,2),(1,2)],3) => 2 ([(0,1),(0,2),(1,2)],3) => 3 ([],4) => 1 ([(2,3)],4) => 2 ([(1,3),(2,3)],4) => 2 ([(0,3),(1,3),(2,3)],4) => 2 ([(0,3),(1,2)],4) => 2 ([(0,3),(1,2),(2,3)],4) => 2 ([(1,2),(1,3),(2,3)],4) => 3 ([(0,2),(0,3),(1,2),(1,3)],4) => 3 ([(0,1),(0,2),(0,3),(1,2),(1,3),(2,3)],4) => 4 ([],5) => 1 ([(3,4)],5) => 2 ([(2,4),(3,4)],5) => 2 ([(1,4),(2,4),(3,4)],5) => 2 ([(0,4),(1,4),(2,4),(3,4)],5) => 2 ([(1,4),(2,3)],5) => 2 ([(1,4),(2,3),(3,4)],5) => 2 ([(0,1),(2,4),(3,4)],5) => 2 ([(2,3),(2,4),(3,4)],5) => 3 ([(0,4),(1,4),(2,3),(3,4)],5) => 2 ([(1,3),(1,4),(2,3),(2,4)],5) => 3 ([(0,4),(1,3),(2,3),(2,4)],5) => 2 ([(0,1),(2,3),(2,4),(3,4)],5) => 3 ([(0,3),(0,4),(1,2),(1,4),(2,3)],5) => 2 ([(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)],5) => 4 ([(0,1),(0,2),(0,3),(0,4),(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)],5) => 5 ([],6) => 1 ([(4,5)],6) => 2 ([(3,5),(4,5)],6) => 2 ([(2,5),(3,5),(4,5)],6) => 2 ([(1,5),(2,5),(3,5),(4,5)],6) => 2 ([(0,5),(1,5),(2,5),(3,5),(4,5)],6) => 2 ([(2,5),(3,4)],6) => 2 ([(2,5),(3,4),(4,5)],6) => 2 ([(1,2),(3,5),(4,5)],6) => 2 ([(3,4),(3,5),(4,5)],6) => 3 ([(1,5),(2,5),(3,4),(4,5)],6) => 2 ([(0,1),(2,5),(3,5),(4,5)],6) => 2 ([(0,5),(1,5),(2,5),(3,4),(4,5)],6) => 2 ([(2,4),(2,5),(3,4),(3,5)],6) => 3 ([(0,5),(1,5),(2,4),(3,4)],6) => 2 ([(0,5),(1,5),(2,3),(3,4),(4,5)],6) => 2 ([(0,5),(1,5),(2,4),(3,4),(4,5)],6) => 2 ([(0,5),(1,4),(2,3)],6) => 2 ([(1,5),(2,4),(3,4),(3,5)],6) => 2 ([(0,1),(2,5),(3,4),(4,5)],6) => 2 ([(1,2),(3,4),(3,5),(4,5)],6) => 3 ([(0,5),(1,4),(2,3),(3,5),(4,5)],6) => 2 ([(1,4),(1,5),(2,3),(2,5),(3,4)],6) => 2 ([(0,5),(1,4),(2,3),(2,4),(3,5)],6) => 2 ([(0,1),(2,4),(2,5),(3,4),(3,5)],6) => 3 ([(0,5),(1,5),(2,3),(2,4),(3,4)],6) => 3 ([(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6) => 4 ([(0,4),(0,5),(1,2),(1,3),(2,5),(3,4)],6) => 3 ([(0,4),(0,5),(1,2),(1,3),(2,3),(4,5)],6) => 3 ([(0,1),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6) => 4 ([(1,2),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6) => 5 ([(0,1),(0,2),(0,3),(0,4),(0,5),(1,2),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)],6) => 6 ([(0,6),(1,6),(2,6),(3,6),(4,6),(5,6)],7) => 2 ([(0,6),(1,6),(2,6),(3,6),(4,5),(5,6)],7) => 2 ([(0,6),(1,6),(2,6),(3,4),(4,5),(5,6)],7) => 2 ([(0,6),(1,6),(2,6),(3,5),(4,5),(5,6)],7) => 2 ([(0,6),(1,6),(2,5),(3,5),(4,5),(4,6)],7) => 2 ([(0,6),(1,6),(2,5),(3,4),(4,6),(5,6)],7) => 2 ([(0,6),(1,6),(2,3),(3,5),(4,5),(4,6)],7) => 2 ([(0,6),(1,4),(2,3),(3,6),(4,5),(5,6)],7) => 2 ([(0,6),(1,5),(2,5),(3,4),(4,6),(5,6)],7) => 2 ([(0,5),(1,4),(2,3),(3,6),(4,6),(5,6)],7) => 2 ([(0,6),(1,5),(2,3),(2,4),(3,5),(4,6)],7) => 2 ([(0,5),(0,6),(1,2),(1,4),(2,3),(3,5),(4,6)],7) => 2 ([(1,2),(1,3),(1,4),(1,5),(1,6),(2,3),(2,4),(2,5),(2,6),(3,4),(3,5),(3,6),(4,5),(4,6),(5,6)],7) => 6 ([(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),(1,2),(1,3),(1,4),(1,5),(1,6),(2,3),(2,4),(2,5),(2,6),(3,4),(3,5),(3,6),(4,5),(4,6),(5,6)],7) => 7 ([(0,7),(1,6),(2,3),(2,4),(3,5),(4,6),(5,7)],8) => 2 ([(0,6),(1,7),(2,7),(3,4),(3,5),(4,6),(5,7)],8) => 2 ([(0,6),(1,5),(2,7),(3,4),(3,5),(4,7),(6,7)],8) => 2 ([(0,6),(1,5),(2,7),(3,5),(3,7),(4,6),(4,7)],8) => 2 ([(0,7),(1,6),(2,6),(3,5),(4,5),(4,7),(6,7)],8) => 2 ([(0,6),(1,5),(2,4),(3,4),(3,7),(5,7),(6,7)],8) => 2 ([(0,7),(1,6),(2,6),(3,4),(4,7),(5,6),(5,7)],8) => 2 ([(0,7),(1,6),(2,4),(3,5),(4,6),(5,7),(6,7)],8) => 2 ([(0,6),(1,6),(2,5),(3,4),(4,7),(5,7),(6,7)],8) => 2 ([(0,6),(1,6),(2,7),(3,7),(4,5),(4,7),(5,6)],8) => 2 ([(0,6),(1,6),(2,5),(3,5),(4,7),(5,7),(6,7)],8) => 2 ([(0,7),(1,7),(2,7),(3,7),(4,7),(5,7),(6,7)],8) => 2 ([(0,7),(1,7),(2,7),(3,7),(4,7),(5,6),(6,7)],8) => 2 ([(0,7),(1,7),(2,7),(3,7),(4,6),(5,6),(6,7)],8) => 2 ([(0,7),(1,7),(2,7),(3,7),(4,5),(5,6),(6,7)],8) => 2 ([(0,7),(1,7),(2,7),(3,6),(4,5),(5,7),(6,7)],8) => 2 ([(0,7),(1,7),(2,7),(3,6),(4,6),(5,6),(6,7)],8) => 2 ([(0,7),(1,7),(2,7),(3,6),(4,5),(5,6),(6,7)],8) => 2 ([(0,7),(1,7),(2,7),(3,6),(4,6),(5,6),(5,7)],8) => 2 ([(0,7),(1,7),(2,7),(3,4),(4,6),(5,6),(5,7)],8) => 2 ([(0,7),(1,7),(2,6),(3,6),(4,5),(5,7),(6,7)],8) => 2 ([(0,7),(1,7),(2,5),(3,4),(4,7),(5,6),(6,7)],8) => 2 ([(0,7),(1,6),(2,5),(3,4),(4,7),(5,7),(6,7)],8) => 2 ([(0,6),(0,7),(1,2),(1,3),(2,5),(3,4),(4,6),(5,7)],8) => 2 ([(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),(0,7),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(2,3),(2,4),(2,5),(2,6),(2,7),(3,4),(3,5),(3,6),(3,7),(4,5),(4,6),(4,7),(5,6),(5,7),(6,7)],8) => 8 ([(0,8),(1,6),(2,6),(3,7),(4,5),(5,8),(6,7),(7,8)],9) => 2 ([(0,6),(1,6),(2,7),(3,7),(4,8),(5,7),(5,8),(6,8)],9) => 2 ([(0,7),(1,7),(2,6),(3,6),(4,5),(5,8),(6,8),(7,8)],9) => 2 ----------------------------------------------------------------------------- Created: Dec 27, 2018 at 23:53 by Martin Rubey ----------------------------------------------------------------------------- Last Updated: Oct 13, 2019 at 18:44 by Martin Rubey