def test_viztracing_activate_vertex(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)
     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.change_activated_vertex(self.directed_graph, vertex_1)
     for label, vertex in self.directed_graph.get_vertices().items():
         if vertex_1.get_label() == label:
             self.assertTrue(vertex.get_attr(VizTracing.ACTIVATED))
         else:
             self.assertFalse(vertex.get_attr(VizTracing.ACTIVATED))
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()
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()