def main(): m, n = 6, 6 # Set deeper recursion level to avoid max recursion depth exceeded. if m > 5 or n > 5: sys.setrecursionlimit(10000) grid = Grid(2, m, n) # Get vertices in the boundary face. vertices = grid.get_vertices([(1, 1), (0, 1), (0, 0), (1, 0)]) # Create a new pdf file with current timestamp. now = datetime.datetime.now() #primal_pdf = PdfPages('../resources/{}-primal.pdf'.format(now.strftime("%m-%d-%H:%M"))) #dual_pdf = PdfPages('../resources/{}-dual.pdf'.format(now.strftime("%m-%d-%H:%M"))) primal_pdf = None dual_pdf = None vertex_mapping = get_vertex_mapping(grid.genus, grid.width, grid.height) face_mapping = get_face_mapping(grid.genus, grid.width, grid.height) # Wrap all visualization related parameters in tuple. visual_params = (vertex_mapping, face_mapping, primal_pdf, dual_pdf) move_around_face(grid, vertices, visual_params) # Close the pdf files, if created. if primal_pdf is not None: primal_pdf.close() if dual_pdf is not None: dual_pdf.close()
def test_initial_tree_g2(self): # NOTE(lkhamsurenl): Following line is needed if copying graph is too deep, when using copy.deepcopy sys.setrecursionlimit(10000) grid2 = Grid(2, 6, 6) # Source vertex. vertex = grid2.get_vertex((1, 1)) fast_start = time.time() fast_holy_tree = initial_holy_tree.fast_initial_tree(grid2, vertex) fast_end = time.time() slow_holy_tree = initial_holy_tree.bellman_ford_initial_tree(grid2, vertex) slow_end = time.time() print("g = 2 \n fast: {}, slow: {}".format(fast_end - fast_start, slow_end - fast_end)) self.assertEqual(fast_holy_tree, slow_holy_tree)