Skip to content

Commit

Permalink
adding examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Chad-Peterson committed Aug 25, 2024
1 parent d719f0f commit 151cbe6
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 43 deletions.
58 changes: 31 additions & 27 deletions examples/cube/generate_routings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)



Expand Down
30 changes: 14 additions & 16 deletions examples/scratch/example_cube_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -232,9 +232,7 @@
('1', '39'),

# UPDATED

# ('81', '43'),

('43', 'a'),
('a', 'b'),
('b', 'c'),
Expand Down

0 comments on commit 151cbe6

Please sign in to comment.