def test_viztracing_default(self):
     pt.create_dir_in_user_home(TestDirectedGraph.RESOURCES_PATH)
     VizTracing.enable(
         pt.get_dir_in_user_home(TestDirectedGraph.RESOURCES_PATH),
         self.directed_graph)
     VizTracing.snapshot()
     self.assertTrue(True)
 def test_viztracing_vertex_only(self):
     self.vertices = {
         0: [1],
         1: [2, 3],
         2: [3],
         3: [4, 6],
         4: [5, 6],
         5: [5],
         6: [6]
     }
     self.directed_graph = DirectedGraph(self.vertices)
     vertex_1 = self.directed_graph.get_vertex(1)
     vertex_1.set_attr("activated", True)
     vertex_2 = self.directed_graph.get_vertex(2)
     vertex_2.set_attr("in_cycle", True)
     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.snapshot()
     self.assertTrue(True)
def viztrace_log_finish(directed_graph):
    """ Viz traces the first vertex 

    Args:
        directed_graph(DirectedGraph): the directed graph in question

    """

    starting_vertex = next(iter(directed_graph.get_vertices().items()))[1]
    VizTracing.change_activated_vertex(directed_graph, starting_vertex)    
    VizTracing.snapshot()
def viztrace_vertex(directed_graph, vertex):
    """ Changes focus to the vertex and takes a snapshot

    Args:
        directed_graph (DirectedGraph): The directed graph
        vertex: the vertex that should get the status activated

    """

    VizTracing.change_activated_vertex(directed_graph, vertex)
    VizTracing.snapshot()
Esempio n. 5
0
 def test_viztracing_snapshot(self):
     pt.create_dir_in_user_home(TestDirectedGraph.RESOURCES_PATH)
     VizTracing.enable(pt.get_dir_in_user_home(TestDirectedGraph.RESOURCES_PATH), self.directed_graph)
     VizTracing.snapshot() 
     self.assertTrue(os.path.exists(path.join(pt.get_dir_in_user_home(TestDirectedGraph.RESOURCES_PATH),
         VizTracing.IMAGE_NAME_PREFIX + ("{:04d}".format(VizTracing.snapshot_no - 1)) + "." + 
         VizTracing.IMAGE_TYPE)))
     VizTracing.snapshot() 
     self.assertTrue(os.path.exists(path.join(pt.get_dir_in_user_home(TestDirectedGraph.RESOURCES_PATH),
         VizTracing.IMAGE_NAME_PREFIX + ("{:04d}".format(VizTracing.snapshot_no - 1)) + "." + 
         VizTracing.IMAGE_TYPE)))
def viztrace_cycle_found(directed_graph, tail, head):
    """ Changes the state of a vertex when the vertex is part of a cycle

    Args:
        directed_graph (DirectedGraph): The directed graph
        tail: the tail vertex that should get the status activated
        head: the head vertex that should get the in_cycle status

    """
        
    VizTracing.set_status(directed_graph, head, VizTracing.IN_CYCLE)
    VizTracing.change_activated_vertex(directed_graph, head)    
    VizTracing.snapshot()
def viztrace_visit_tail(directed_graph, vertex):
    """ Function that is used to tag vertices with the state "visisted", 
    if these vertices have been visited once. So next time, when another predecessor
    of a tagged vertex is being considered, it is skipped

    Args:
        directed_graph (DirectedGraph): The directed graph
        vertex: the vertex that should get the status "visited"

    """
    VizTracing.change_activated_vertex(directed_graph, vertex)
    VizTracing.set_status(directed_graph, vertex, VizTracing.VISISTED)
    VizTracing.snapshot()
def viztrace_cycle_reported(directed_graph, vertex):
    """ Function that is used along the way back from the origin
    of the cycle detection to the initial state. Along the way,
    all vertices are tagged with the state in_cycle

    Args:
        directed_graph (DirectedGraph): The directed graph
        vertex: the vertex that should get the status activated

    """    
    VizTracing.set_status(directed_graph, vertex, VizTracing.IN_CYCLE)
    VizTracing.change_activated_vertex(directed_graph, vertex)    
    VizTracing.snapshot()