def test_bipartite(adj1, adj2, adj3, adj4, adj5, adj6): assert bipartite(adj1) == 0 # pudb.set_trace() assert bipartite(adj2) == 1 assert bipartite(adj3) == 0 assert bipartite(adj4) == 1 assert bipartite(adj5) == 1 assert bipartite(adj6) == 1
def test_2(self): self.assertEqual(bipartite([[3], [3, 4], [3], [0, 1], [1]]), 1)
def test_1(self): self.assertEqual(bipartite([[1, 3], [0, 2], [0, 1], [0]]), 0)
def test5(self): long_list = [ [] for _ in range(100000) ] result = bipartite(long_list) self.assertEqual(1, result)
def test4(self): result = bipartite([[1], [0], [3], [2]]) self.assertEqual(1, result)
def test3(self): result = bipartite([[], [], [], []]) self.assertEqual(1, result)
def test2(self): result = bipartite([[1, 3, 2], [0, 2], [1, 0], [0]]) self.assertEqual(0, result)
def test1(self): result = bipartite([[3], [4, 3], [3], [1, 2, 0], [1]]) self.assertEqual(1, result)
def stress_test(n_v, n_e): adjs = generate_random_graph(n_v, n_e, n_graphs=100) for adj in adjs: assert bipartite(adj) == bipartite_bfs(adj)