The success probability in Levine's hat problem, and independent sets in graphs