from timeit import timeit import os import shutil TESTS = 10 data_structures = [ Storage.queue, Storage.stack, Storage.multi_queue, Storage.multi_stack ] parameters = [True, False] graph_path = "../test_graphs" complete_path = "../complete_tests" results = "../results/" for g in os.listdir(graph_path): print("Working on graph %s" % g) test_graph = Graph.read_graph(graph_path + '/' + g) print("Starting Edmond-Karp Test...", end=" ") with open(results + 'edmond_karp_results', 'a') as f: ek_test_instance = ek(test_graph) f.write(g + ',') f.write(str(timeit(ek_test_instance.max_flow, number=TESTS) / TESTS)) f.write('\n') print("done") print("Starting Goldberg-Tarjan Test...", end=" ") with open(results + 'goldberg_tarjan_results', 'a') as f: gt_test_instance = gt(test_graph) f.write(g + ',') f.write(str(timeit(gt_test_instance.max_flow, number=TESTS) / TESTS)) f.write('\n') print("done") for data_structure in data_structures:
from util.graph import Graph from util.goldberg_tarjan import Goldberg_Tarjan as gt g = Graph.read_graph('../test_graphs/test0-c50-n300-e600.graph') my_gt = gt(g) my_gt.max_flow()