def test_even_even_harder(self): """Test on map, where all countries each other's neighbors""" count = rnd.randint(10, 500) graph = generate_whole_graph(count) ans = g.painting_graph(graph) ans_br = g.brute_graph(graph) set_br = set(list(ans_br.values())) set_al = set(list(ans.values())) self.assertEqual(len(list(graph.keys())), len(set_br), len(set_al))
def test_harder(self): """Test on Big graph without painting""" size = rnd.randint(10, 1000) graph = generate_empty_graph(size) ans = g.painting_graph(graph) ans_br = g.brute_graph(graph) set_br = set(list(ans_br.values())) set_al = set(list(ans.values())) self.assertEqual(1, len(set_br), len(set_al))
def test_strips(self): """Big striped map""" count = rnd.randint(10, 1000) graph = generate_stripes_graph(count) ans = g.painting_graph(graph) ans_br = g.brute_graph(graph) for i in range(3, count - 1): self.assertAlmostEqual(ans[str(i)], ans[str(i - 2)], delta=2) self.assertAlmostEqual(ans[str(i)], ans[str(i + 2)], delta=2) self.assertAlmostEqual(ans[str(i + 2)], ans[str(i - 2)], delta=2) self.assertEqual(ans_br[str(i)], ans_br[str(i + 2)], ans_br[str(i - 2)])
def test_cake_brute(self): """Test on cake map""" graph = { '1': ['2', '3', '4'], '2': ['1', '3', '4'], '3': ['1', '2', '4'], '4': ['1', '2', '3'] } ans = g.brute_graph(graph) for key1 in ans: for key2 in ans: if key1 != key2: self.assertTrue(ans[key1] != ans[key2])
def test_without_painting_brute(self): """Test func on islands""" graph = {'1': [], '2': [], '3': []} ans = g.brute_graph(graph) for key in ans: self.assertEqual(ans[key], 0)