"""
=============
Parsing knots
=============

Test various knot/graph notations.
"""

import knotpy as kp


print("PD notation\n")

# Mathematica format
text = "X[1,9,2,8], X[3,10,4,11], X[5,3,6,2], X[7,1,8,12], X[9,4,10,5], X[11,7,12,6]"
print("In:", text)
print("Out:", k := kp.from_pd_notation(text))
print("Out:", kp.to_pd_notation(k))

print()

# KnotInfo notation
text = "[[4,2,5,1],[8,6,1,5],[6,3,7,4],[2,7,3,8]]"
print("In:", text)
print("Out:", k := kp.from_pd_notation(text))
print("Out:", kp.to_pd_notation(k))

print()

# Topoly notation
text = "V[12,14,5],V[14,13,2],X[11,10,13,12],X[7,11,5,6],X[10,7,6,2]"
print("In:", text)
print("Out:", k := kp.from_pd_notation(text))
print("Out:", kp.to_pd_notation(k))

print("\nEM notation\n")

text = "b0e1,a0c0d0,b1d1,b2c1e0,d2a1"
print("In:", text)
print("Out:", k := kp.from_condensed_em_notation(text))
print("Out:", kp.to_condensed_em_notation(k))

print("\nKnot notation\n")
PD notation

In: X[1,9,2,8], X[3,10,4,11], X[5,3,6,2], X[7,1,8,12], X[9,4,10,5], X[11,7,12,6]
Out: Diagram a → X(d1 e0 c3 d2), b → X(c1 e2 e1 f0), c → X(e3 b0 f3 a2), d → X(f1 a0 a3 f2), e → X(a1 b2 b1 c0), f → X(b3 d0 d3 c2)
Out: X[0,1,2,3],X[4,5,6,7],X[8,4,9,2],X[10,0,3,11],X[1,6,5,8],X[7,10,11,9]

In: [[4,2,5,1],[8,6,1,5],[6,3,7,4],[2,7,3,8]]
Out: Diagram a → X(c3 d0 b3 b2), b → X(d3 c0 a3 a2), c → X(b1 d2 d1 a0), d → X(a1 c2 c1 b0)
Out: X[0,1,2,3],X[4,5,3,2],X[5,6,7,0],X[1,7,6,4]

In: V[12,14,5],V[14,13,2],X[11,10,13,12],X[7,11,5,6],X[10,7,6,2]
Out: Diagram a → V(c3 b0 d2), b → V(a1 c2 e3), c → X(d1 e0 b1 a0), d → X(e1 c0 a2 e2), e → X(c1 d0 d3 b2)
Out: V[0,1,2],V[1,3,4],X[5,6,3,0],X[7,5,2,8],X[6,7,8,4]

EM notation

In: b0e1,a0c0d0,b1d1,b2c1e0,d2a1
Out: Diagram a → V(b0 e1), b → V(a0 c0 d0), c → V(b1 d1), d → V(b2 c1 e0), e → V(d2 a1)
Out: b0e1,a0c0d0,b1d1,b2c1e0,d2a1

Knot notation