def ta(G, var): """ Returns a list of the visited nodes which contains the command 'assign' from the graph G crossed by variables initialized in 'var' """ # Initialization assign_list = [] cmd, curr_node = initialization(G, var) # Crossing the graph while cmd != "end": if cmd == 'assign': assign_list.append(curr_node) cmd, curr_node = parcours_graph(G, cmd, curr_node, var) # End G.nodes[curr_node]['msg'](var) return assign_list
def td(G, var, res): """ Returns a list of the visited nodes which contains the command 'while' or 'if' from the graph G crossed by variables initialized in 'var' """ # Initialization cmd, curr_node = initialization(G, var) # Crossing the graph while cmd != "end": if cmd in ['if', 'while']: for edge in G.edges(curr_node, data=True): if (edge[2]['bool'](var)) & (curr_node not in res): res[curr_node] = [edge[1]] elif (edge[2]['bool'](var)) & (curr_node in res): if edge[1] not in res[curr_node]: res[curr_node].append(edge[1]) cmd, curr_node = parcours_graph(G, cmd, curr_node, var) # End G.nodes[curr_node]['msg'](var) return res
def tu(G, var, label_assign): """ Returns label_assign updated by the crossing of the graph G with the variables var """ # Initialization cmd, curr_node = initialization(G, var) last_assign = 0 # Crossing the graph while cmd != "end": if cmd == "if": for edge in G.edges(curr_node, data=True): if edge[1] > curr_node: if edge[2]['bool'](var): try: # La condition a été executée POUR le last_assign traversé label_assign[last_assign][curr_node].remove( edge[1]) except ValueError: pass except KeyError: pass elif cmd == "assign": # On garde une trace du dernier assign traversé last_assign = curr_node elif cmd == "while": for edge in G.edges(curr_node, data=True): if edge[1] > curr_node: if edge[2]['bool'](var): try: # La condition a été executée POUR le last_assign traversé label_assign[last_assign][curr_node].remove( edge[1]) except ValueError: pass except KeyError: pass cmd, curr_node = parcours_graph(G, cmd, curr_node, var) # End G.nodes[curr_node]['msg'](var) return label_assign
def itb(G, var, i): """ Returns True if the criteria i_tb is verified for the graph G crossed by var """ # Initialization cmd, curr_node = initialization(G, var) labels_while = extract_labels(G) # Crossing the graph while cmd != "end": if cmd == "while": for edge in G.edges(curr_node, data=True): if edge[2]['bool'](var): labels_while[curr_node] = labels_while[curr_node] + 1 cmd, curr_node = parcours_graph(G, cmd, curr_node, var) # End G.nodes[curr_node]['msg'](var) respect = verify_criteria(labels_while, i) return respect
def k_tc(G, var, node, k): """ Crosses the graph with an initial variables' set and returns a k_path from the origin node""" # Initialization cmd, curr_node = initialization(G, var) # Crossing the graph until we reach the node while (cmd != "end") & (curr_node != node): cmd, curr_node = parcours_graph(G, cmd, curr_node, var) # Creation of the path list path = [curr_node] # Crossing the graph and adding the current node to the path while (cmd != "end") & (len(path) != k + 1): cmd, curr_node = parcours_graph(G, cmd, curr_node, var) path.append(curr_node) # End while (cmd != "end"): cmd, curr_node = parcours_graph(G, cmd, curr_node, var) G.nodes[curr_node]['msg'](var) return path
def t_def(cfg, var, assign_dict): """ Returns a list of the visited nodes which contains the command 'while' or 'if' from the graph G crossed by variables initialized in 'var' """ # Initialization G = cfg.graph cmd, curr_node = initialization(G, var) # Crossing the graph while cmd != "end": for edge in G.edges(curr_node, data=True): if edge[2]['cmd'] == 'assign': for x in edge[2]['var']: try: if curr_node not in assign_dict[x]: assign_dict[x].append(curr_node) except KeyError: assign_dict[x] = [curr_node] except TypeError: assign_dict[x] = [curr_node] cmd, curr_node = parcours_graph(G, cmd, curr_node, var) # End G.nodes[curr_node]['msg'](var) return assign_dict