def main(algo): print('New/load ? n / l') ans = input() if ans == 'n': input_message = "Enter the size of your maze (height x width)\n" maze_height, maze_width = map(int, input(input_message).split()) graph = Graph(maze_height, maze_width) if algo == 1: dfs_generation(graph) print("Generating with DFS...") elif algo == 2: kruskal_generation(graph) print("Generating with Kruskal algorithm") m = create_maze(graph) print_maze(m) print('Would you like to save it? y/n') ans = input() if ans == 'y': write_maze(m) else: print('Enter file name') file = input() m = open_maze(file) print('Would you like to solve it? y/n') ans = input() if ans == 'y': bfs(m) print_maze(m)
def test_big_input_dfs_case(): start_time = time.time() graph = Graph(50, 50) dfs_generation(graph) test_time = time.time() - start_time print("time for input 50x50 dfs is", test_time) assert test_time < 2
def test_10x10_dfs_case(): start_time = time.time() graph = Graph(10, 10) dfs_generation(graph) test_time = time.time() - start_time print("dfs 10x10", test_time)
def test_2x2_dfs_case(): start_time = time.time() graph = Graph(2, 2) dfs_generation(graph) test_time = time.time() - start_time print("dfs 2x2", test_time)
def test_4x4_dfs_case(): start_time = time.time() graph = Graph(4, 4) dfs_generation(graph) test_time = time.time() - start_time print("dfs 4x4", test_time)
def test_3x3_dfs_case(): start_time = time.time() graph = Graph(3, 3) dfs_generation(graph) test_time = time.time() - start_time print("dfs 3x3", test_time)
from Graph import Graph, dfs_generation, kruskal_generation import time for i in range(2, 21): start_time = time.time() graph = Graph(i, i) dfs_generation(graph) print("dfs {0} x {1} ".format(i, i) + str(time.time() - start_time)) for i in range(2, 21): start_time = time.time() graph = Graph(i, i) kruskal_generation(graph) print("kruskal {0} x {1} ".format(i, i) + str(time.time() - start_time))