Esempio n. 1
0
 def test_detect_no_cycles(self):
     self.assertEqual(self.G.v(), self.N)
     algorithm = AcyclicGraphDFS(self.G)
     algorithm.run(1)  # it is safe, because G is connected
     parent_expected = {1: None, 0: 1, 3: 6, 2: 5, 5: 1, 4: 0, 7: 6, 6: 2}
     self.assertEqual(algorithm.parent, parent_expected)
     self.assertTrue(is_acyclic(self.G))
Esempio n. 2
0
 def test_detect_no_cycles(self):
     self.assertEqual(self.G.v(), self.N)
     algorithm = AcyclicGraphDFS(self.G)
     algorithm.run(1)   # it is safe, because G is connected
     parent_expected = {1: None, 0: 1, 3: 6, 2: 5, 5: 1, 4: 0, 7: 6, 6: 2}
     self.assertEqual(algorithm.parent, parent_expected)
     self.assertTrue(is_acyclic(self.G))
Esempio n. 3
0
 def test_detect_no_directed_cycles(self):
     self.assertEqual(self.G.v(), self.N)
     algorithm = AcyclicGraphDFS(self.G)
     algorithm.run(0)  # in order to easy test
     parent_expected = {0: None, 2: 1, 1: 0, 4: 0, 3: 2, 6: 5, 5: 4, 7: 5}
     #parent_expected = {0: None, 2: 1, 1: 0, 4: 0, 3: 2, 6: 5, 5: 4, 7: 0}
     self.assertEqual(algorithm.parent, parent_expected)
     self.assertTrue(is_acyclic(self.G))
Esempio n. 4
0
 def test_detect_no_directed_cycles(self):
     self.assertEqual(self.G.v(), self.N)
     algorithm = AcyclicGraphDFS(self.G)
     algorithm.run(0)   # in order to easy test
     parent_expected = {0: None, 2: 1, 1: 0, 4: 0, 3: 2, 6: 5, 5: 4, 7: 5}
     #parent_expected = {0: None, 2: 1, 1: 0, 4: 0, 3: 2, 6: 5, 5: 4, 7: 0}
     self.assertEqual(algorithm.parent, parent_expected)
     self.assertTrue(is_acyclic(self.G))