def test_acyclic(self):
     Logging.enable()
     self.vertices = {
         0: [1],
         1: [2, 3],
         2: [3],
         3: [4, 6],
         4: [5, 6],
         5: [],
         6: []
     }
     self.directed_graph = DirectedGraph(self.vertices)
     self.assertFalse(self.directed_graph.is_cyclic())
 def test_cyclic(self):
     Logging.enable()
     self.vertices = {
         0: [1],
         1: [2, 3],
         2: [3],
         3: [4],
         4: [5, 2],
         5: [6],
         6: [7],
         7: [5]
     }
     self.directed_graph = DirectedGraph(self.vertices)
     self.assertTrue(self.directed_graph.is_cyclic())
Пример #3
0
 def test_viztracing_cyclic(self):
     Logging.enable()
     self.vertices = {0: [1], 1: [2, 3], 2: [3],
                      3: [4, 6], 4: [5, 6], 5: [7, 8], 6:[7, 8], 
                      7: [9, 10, 11], 8: [3], 9: [], 
                      10: [11], 11: [12], 12: []}
     self.directed_graph = DirectedGraph(self.vertices)        
     pt.create_dir_in_user_home(TestDirectedGraph.RESOURCES_PATH)
     VizTracing.enable(
         pt.get_dir_in_user_home(TestDirectedGraph.RESOURCES_PATH), 
         self.directed_graph,
         vertex_states=[
                 {VizTracing.ACTIVATED: {"fillcolor":"red", "style": "filled"}}, 
                 {VizTracing.IN_CYCLE: {"fillcolor":"blue", "style": "filled"}},
                 {VizTracing.VISISTED: {"fillcolor":"gray", "style": "filled"}}])
     self.assertTrue(self.directed_graph.is_cyclic())