Exemple #1
0
 def test_find_bipartite_3(self):
     g = Graph({1: [2, 3], 4: [2, 3, 5], 5: [6, 7, 8], 7: [9]})
     a, b = find_bipartite(g)
     if len(a) > len(b):
         a, b = b, a
     self.assertEqual(b, [1, 4, 6, 7, 8])
     self.assertEqual(a, [2, 3, 5, 9])
     self.assertTrue(is_bipartite(g))
Exemple #2
0
 def test_find_bipartite_2(self):
     g = Graph({5: [1, 2, 3]})
     a, b = find_bipartite(g)
     if len(a) > len(b):
         a, b = b, a
     self.assertEqual(a, [5])
     self.assertEqual(b, [1, 2, 3])
     self.assertTrue(is_bipartite(g))
Exemple #3
0
 def test_is_bipartite_6(self):
     g = Graph({1: [2]})
     self.assertTrue(is_bipartite(g))
Exemple #4
0
 def test_is_bipartite_5(self):
     g = Graph({1: [], 2: []})
     self.assertTrue(is_bipartite(g))
Exemple #5
0
 def test_is_bipartite_4(self):
     g = Graph({1: [2, 3], 2: [3]})
     self.assertFalse(is_bipartite(g))
Exemple #6
0
 def test_is_bipartite_3(self):
     g = Graph({1: [2, 3], 4: [2, 3]})
     self.assertTrue(is_bipartite(g))
Exemple #7
0
 def test_is_bipartite_2(self):
     g = Graph({5: [1, 2, 3]})
     self.assertTrue(is_bipartite(g))
Exemple #8
0
 def test_is_bipartite_1(self):
     g = Graph({5: []})
     self.assertFalse(is_bipartite(g))