From 151cbe6c07db4644372e29d0b4106cc20f74a130 Mon Sep 17 00:00:00 2001 From: Chad-Peterson <97306485+Chad-Peterson@users.noreply.github.com> Date: Sun, 25 Aug 2024 00:28:35 -0500 Subject: [PATCH] adding examples --- examples/cube/generate_routings.py | 58 ++++++++++++++++-------------- examples/scratch/example_cube_4.py | 30 ++++++++-------- 2 files changed, 45 insertions(+), 43 deletions(-) diff --git a/examples/cube/generate_routings.py b/examples/cube/generate_routings.py index 84128cb..5a08976 100644 --- a/examples/cube/generate_routings.py +++ b/examples/cube/generate_routings.py @@ -6,8 +6,8 @@ from networkx.algorithms.approximation import traveling_salesman_problem # TODO Replace random, but use a seed for reproducibility for now -random.seed(0) -np.random.seed(0) +# random.seed(0) +# np.random.seed(0) def create_grid_graph(size): # Create a 3D grid graph with the specified size @@ -153,10 +153,14 @@ def draw_graph(grid, cube_corners, edge_paths): # m = 5 # Size of the cube # k = 2 # Number of waypoints # l = 3 # Minimum distance from the original path nodes +# n = 10 # Size of the grid +# m = 4 # Size of the cube +# k = 1 # Number of waypoints +# l = 2 # Minimum distance from the original path nodes n = 10 # Size of the grid -m = 5 # Size of the cube +m = 4 # Size of the cube k = 1 # Number of waypoints -l = 2 # Minimum distance from the original path nodes +l = 0 # Minimum distance from the original path nodes grid = create_grid_graph(n) cube_corners = select_cube_corners(n, m) @@ -194,29 +198,29 @@ def draw_graph(grid, cube_corners, edge_paths): -from yamada import SpatialGraph -from yamada.Reidemeister import * - -# Instantiate the SpatialGraph object -sg = SpatialGraph(nodes=nodes, - node_positions=node_positions, - edges=edges) - -# # Plot the Spatial Graph in 3D and the projected 2D plane to see what's going on. Crossings will be circled in red. -# # Note: Crossings occur when two edges that do not intersect, but appear to when they are projected onto a 2D plane. -# # sg.plot() - -# Create the spatial graph diagram (necessary for calculating the Yamada polynomial) -sgd = sg.create_spatial_graph_diagram() - -# TODO Fix -# n=19 works, n=20 does not -sgd, r1_count, r2_count, r3_count = reidemeister_simplify(sgd, n_tries=100) - -print(f"R1: {r1_count}, R2: {r2_count}, R3: {r3_count}, Remaining Crossings: {len(sgd.crossings)}") - -# yp = sgd.normalized_yamada_polynomial() -# print(yp) +# from yamada import SpatialGraph +# from yamada.Reidemeister import * +# +# # Instantiate the SpatialGraph object +# sg = SpatialGraph(nodes=nodes, +# node_positions=node_positions, +# edges=edges) +# +# # # Plot the Spatial Graph in 3D and the projected 2D plane to see what's going on. Crossings will be circled in red. +# # # Note: Crossings occur when two edges that do not intersect, but appear to when they are projected onto a 2D plane. +# # # sg.plot() +# +# # Create the spatial graph diagram (necessary for calculating the Yamada polynomial) +# sgd = sg.create_spatial_graph_diagram() +# +# # TODO Fix +# # n=19 works, n=20 does not +# sgd, r1_count, r2_count, r3_count = reidemeister_simplify(sgd, n_tries=100) +# +# print(f"R1: {r1_count}, R2: {r2_count}, R3: {r3_count}, Remaining Crossings: {len(sgd.crossings)}") +# +# # yp = sgd.normalized_yamada_polynomial() +# # print(yp) diff --git a/examples/scratch/example_cube_4.py b/examples/scratch/example_cube_4.py index 851f70b..e275231 100644 --- a/examples/scratch/example_cube_4.py +++ b/examples/scratch/example_cube_4.py @@ -109,21 +109,21 @@ # '81': (3, 6, 6), 'a': (2.15, 6, 6), - 'b': (2.15, 6.1, 6), - 'c': (2.15, 6.1, 6.1), - 'd': (2.35, 6.1, 6.1), - 'e': (2.35, 6.1, 5.9), - 'f': (2.65, 6.1, 5.9), - 'g': (2.65, 6.1, 6), - 'h': (2.65, 5.9, 6), - 'i': (2.45, 5.9, 6), - 'j': (2.45, 6.2, 6), - 'k': (2.25, 6.2, 6), + 'b': (2.15, 6.2, 6), + 'c': (2.15, 6.2, 6.2), + 'd': (2.35, 6.2, 6.2), + 'e': (2.35, 6.2, 5.8), + 'f': (2.65, 6.2, 5.8), + 'g': (2.65, 6.2, 6), + 'h': (2.65, 5.8, 6), + 'i': (2.45, 5.8, 6), + 'j': (2.45, 6.4, 6), + 'k': (2.25, 6.4, 6), 'l': (2.25, 6, 6), - 'm': (2.25, 6, 6.1), - 'n': (2.55, 6, 6.1), - 'o': (2.55, 6, 5.9), - 'p': (2.75, 6, 5.9), + 'm': (2.25, 6, 6.2), + 'n': (2.55, 6, 6.2), + 'o': (2.55, 6, 5.8), + 'p': (2.75, 6, 5.8), 'q': (2.75, 6, 6), 'r': (2.85, 6, 6) @@ -232,9 +232,7 @@ ('1', '39'), # UPDATED - # ('81', '43'), - ('43', 'a'), ('a', 'b'), ('b', 'c'),