import numpy as np
import matplotlib.pyplot as plt
# Try SnapPy import
try:
import snappy
SNAPPY_AVAILABLE = True
print(f"SnapPy version: {snappy.version()} — knot computation available")
except ImportError:
SNAPPY_AVAILABLE = False
print("SnapPy not available — using Knot Atlas reference data only")
print("Install: pip install snappy")
# Knot Atlas reference data (verified from katlas.org)
KNOT_ATLAS = {
"3_1 (Trefoil)": {
"snappy_name": "3_1",
"pd": [(4, 1, 2, 5), (2, 6, 3, 1), (6, 4, 5, 3)],
"alexander": "t - 1 + t^{-1}",
"jones": "-t^{-4} + t^{-3} + t^{-1}",
"determinant": 3,
"signature": -2,
"unknotting": 1,
"tricolorable": True,
"slice": False,
},
"4_1 (Figure-eight)": {
"snappy_name": "4_1",
"pd": [(4, 1, 5, 2), (6, 4, 7, 3), (8, 6, 1, 5), (2, 8, 3, 7)],
"alexander": "-t + 3 - t^{-1}",
"jones": "t^2 - t + 1 - t^{-1} + t^{-2}",
"determinant": 5,
"signature": 0,
"unknotting": 1,
"tricolorable": False,
"slice": True,
},
"K11n34 (Conway)": {
"snappy_name": "K11n34",
"pd": [(6, 2, 7, 1), (16, 4, 17, 3), (10, 6, 11, 5), (2, 14, 3, 13),
(8, 18, 9, 17), (20, 10, 21, 9), (4, 20, 5, 19), (22, 12, 1, 11),
(14, 22, 15, 21), (18, 16, 19, 15), (12, 8, 13, 7)],
"alexander": "1",
"jones": "-t^{-2} + 2t^{-1} - 2 + 2t - t^2",
"determinant": 1,
"signature": 0,
"unknotting": "?",
"tricolorable": False,
"slice_topological": True,
"slice_smooth": False,
},
"K11n42 (Kinoshita-Terasaka)": {
"snappy_name": "K11n42",
"pd": [(6, 2, 7, 1), (16, 4, 17, 3), (10, 6, 11, 5), (2, 14, 3, 13),
(8, 18, 9, 17), (20, 10, 21, 9), (4, 20, 5, 19), (22, 12, 1, 11),
(14, 22, 15, 21), (18, 16, 19, 15), (12, 8, 13, 7)],
"alexander": "1",
"jones": "-t^{-2} + 2t^{-1} - 2 + 2t - t^2",
"determinant": 1,
"signature": 0,
"unknotting": "?",
"tricolorable": False,
"slice_topological": True,
"slice_smooth": True,
},
"K11n102 (Lidman)": {
"snappy_name": "K11n102",
"pd": [(4, 2, 5, 1), (10, 3, 11, 4), (5, 14, 6, 15), (7, 12, 8, 13),
(9, 19, 10, 18), (2, 11, 3, 12), (13, 6, 14, 7), (15, 22, 16, 1),
(17, 20, 18, 21), (19, 9, 20, 8), (21, 16, 22, 17)],
"alexander": "-t^2 + t + 1 + t^{-1} - t^{-2}",
"conway": "-z^4 - 3z^2 + 1",
"jones": "-t^{-4} + 2t^{-3} - 3t^{-2} + 3t^{-1} - 3 + 3t - 2t^2 + t^3",
"determinant": 3,
"signature": -2,
"unknotting": 2,
"rasmussen_s": 2,
"volume": 7.24432,
"tricolorable": False,
},
}
print(f"Loaded {len(KNOT_ATLAS)} knots from Knot Atlas reference data")