Skip to content

Commit

Permalink
Revising R2 Move
Browse files Browse the repository at this point in the history
  • Loading branch information
Chad-Peterson committed Feb 28, 2024
1 parent b57170d commit b1cc798
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 25 deletions.
51 changes: 31 additions & 20 deletions src/yamada/spatial_graph_diagrams/Reidemeister.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ def r2(sgd, crossing_pair, edge_pair):
4. Delete the crossings
5. Create two new edges
6. Connect the new edges to the far side vertices/crossings
sgd.remove_crossing_fuse_edges(crossing_a)
sgd.remove_crossing_fuse_edges(crossing_b)
sgd._merge_edges()
"""

# Make a copy of the sgd object
Expand All @@ -104,32 +110,37 @@ def r2(sgd, crossing_pair, edge_pair):
edge2_flipside2, edge2_flipside2_index = find_flipside_edge(crossing2, edge2)

# Find the far side vertices/crossings
edge1_farsidevertex_1, edge1_farsidevertex_1_index = [adjacent for adjacent in edge1_flipside1.adjacent if adjacent[0] != crossing1][0]
edge1_farsidevertex_2, edge1_farsidevertex_2_index = [adjacent for adjacent in edge1_flipside2.adjacent if adjacent[0] != crossing2][0]
edge2_farsidevertex_1, edge2_farsidevertex_1_index = [adjacent for adjacent in edge2_flipside1.adjacent if adjacent[0] != crossing1][0]
edge2_farsidevertex_2, edge2_farsidevertex_2_index = [adjacent for adjacent in edge2_flipside2.adjacent if adjacent[0] != crossing2][0]

# Remove the edges
sgd.remove_edge(edge1)
sgd.remove_edge(edge2)
sgd.remove_edge(edge1_flipside1)
sgd.remove_edge(edge1_flipside2)
sgd.remove_edge(edge2_flipside1)
sgd.remove_edge(edge2_flipside2)
# edge1_farsidevertex_1, edge1_farsidevertex_1_index = [adjacent for adjacent in edge1_flipside1.adjacent if adjacent[0] != crossing1][0]
# edge1_farsidevertex_2, edge1_farsidevertex_2_index = [adjacent for adjacent in edge1_flipside2.adjacent if adjacent[0] != crossing2][0]
# edge2_farsidevertex_1, edge2_farsidevertex_1_index = [adjacent for adjacent in edge2_flipside1.adjacent if adjacent[0] != crossing1][0]
# edge2_farsidevertex_2, edge2_farsidevertex_2_index = [adjacent for adjacent in edge2_flipside2.adjacent if adjacent[0] != crossing2][0]

# Remove the crossings
sgd.remove_crossing(crossing1)
sgd.remove_crossing(crossing2)

# Create two new edges
new_edge1_label = 'ne' + str(len(sgd.edges) + 1)
new_edge2_label = 'ne' + str(len(sgd.edges) + 2)

new_edge1 = Edge(new_edge1_label)
new_edge2 = Edge(new_edge2_label)
# Remove the edges
sgd.remove_edge(edge1)
sgd.remove_edge(edge2)

sgd.add_edge(new_edge1, edge1_farsidevertex_1, edge1_farsidevertex_1_index, edge1_farsidevertex_2, edge1_farsidevertex_2_index)
sgd.add_edge(new_edge2, edge2_farsidevertex_1, edge2_farsidevertex_1_index, edge2_farsidevertex_2, edge2_farsidevertex_2_index)
# Fuse the flipside edges
sgd.fuse_edges((edge1_flipside1, edge1_flipside1_index), (edge1_flipside2, edge1_flipside2_index))
sgd.fuse_edges((edge2_flipside1, edge2_flipside1_index), (edge2_flipside2, edge2_flipside2_index))

# sgd.remove_edge(edge1_flipside1)
# sgd.remove_edge(edge1_flipside2)
# sgd.remove_edge(edge2_flipside1)
# sgd.remove_edge(edge2_flipside2)

# # Create two new edges
# new_edge1_label = 'ne' + str(len(sgd.edges) + 1)
# new_edge2_label = 'ne' + str(len(sgd.edges) + 2)
#
# new_edge1 = Edge(new_edge1_label)
# new_edge2 = Edge(new_edge2_label)
#
# sgd.add_edge(new_edge1, edge1_farsidevertex_1, edge1_farsidevertex_1_index, edge1_farsidevertex_2, edge1_farsidevertex_2_index)
# sgd.add_edge(new_edge2, edge2_farsidevertex_1, edge2_farsidevertex_1_index, edge2_farsidevertex_2, edge2_farsidevertex_2_index)


return sgd
Expand Down
14 changes: 9 additions & 5 deletions tests/test_spatial_graph_diagrams/test_Reidemeister_2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {
"collapsed": true
"collapsed": true,
"ExecuteTime": {
"end_time": "2024-02-28T22:19:58.960308300Z",
"start_time": "2024-02-28T22:19:58.065826100Z"
}
},
"outputs": [],
"source": [
Expand All @@ -25,7 +29,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"outputs": [],
"source": [
"def test_r2():\n",
Expand Down Expand Up @@ -60,8 +64,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-10-25T15:31:20.548214300Z",
"start_time": "2023-10-25T15:31:20.528130800Z"
"end_time": "2024-02-28T22:19:58.975984500Z",
"start_time": "2024-02-28T22:19:58.964310200Z"
}
}
}
Expand Down

0 comments on commit b1cc798

Please sign in to comment.