def test(func, test_directory): tests = [os.fsdecode(file) for file in os.listdir(test_directory)] success = 0 print("-" * 20 + "TESTS" + "-" * 20) for test in tests: print("Testing...", test) test_path = test_directory + "/" + test print(test_path) solution = readSolution(test_path) actual = func(test_path) print("solution {0}, actual {1}".format(solution, actual), end=" ") if int(actual) == int(solution): print(u"\u2713", end="") success = success + 1 print("\n") print("-" * 50) print("Finished testing {0}/{1} ".format(success, len(tests)) + u"\u2713") print("-" * 50)
return r if False and __name__ == "__main__": TESTS = ["maxclique/clique5", "maxclique/cycle3", "maxclique/house", "maxclique/simple"] import os TESTS = os.listdir("maxclique") for name in TESTS: name = f"maxclique/{name}" correct = int(readSolution(name)) print(name, correct) G = loadGraph(name) result = max_clique(G) if correct ^ result: print(f"FAILED {name}") print(f"EXPECTED {correct}") print(f"GOT {result}") if False and __name__ == "__main__": import sys name = f"maxclique/{sys.argv[1]}" G = loadGraph(name) print([v - 1 for v in LexBFS(G)])