def graph(): wit_folder_path = does_wit_folder_exists() if not wit_folder_path: print("The folder '.wit' does not exists in any of the parent folders and thus the function can not operate.") else: commit_id_list = [] rfr_path = os.path.join(wit_folder_path, 'references.txt') rfr = open(rfr_path, 'r') rfr_lines = rfr.readlines() head = rfr_lines[0].split('=')[1].strip() parent_path = head while parent_path != 'None': path_to_image_file = os.path.join(os.path.join(wit_folder_path, 'images'), parent_path + '.txt') if os.path.exists(path_to_image_file): commit_id_list.append(parent_path) image_file = open(path_to_image_file, 'r') r_image_file = image_file.readlines() parent_path = r_image_file[0].split('=')[1].strip() else: # The parent file does not exist. parent_path = 'None' image_file.close() print(commit_id_list) dot = Digraph('Commit Id Tree', filename='graph_tree', format='png') descriptor = ord('A') for commit_id in commit_id_list: dot.node(chr(descriptor), commit_id) descriptor = descriptor + 1 src = ord('A') dst = ord('B') edges_list = [] for _ in range(len(commit_id_list) - 1): edges_list.append(f'{chr(src)}{chr(dst)}') src = src + 1 dst = dst + 1 print(edges_list) dot.edges(edges_list) dot.fillcolor("Blue") dot.view()