<<KnotTheory`

PD[Knot[3,1]]

pd=PD[X[h[1],4,v[5],5],X[h[2],6,4,h[1]],X[5,v[5],6,h[2]]]

Times@@(pd/.X[i_,j_,k_,l_]:>p[i,k]p[j,l])

edges=DeleteDuplicates[List@@((Times@@(pd/.X[i_,j_,k_,l_]:>p[i,k]p[j,l]))//.{
p[a_,m1___,b_]p[b_,m2___,c_]:>p[a,m1,b,m2,c],
p[a_,m1___,b_]p[c_,m2___,b_]:>p[a,m1,b,Sequence@@Reverse[{m2}],c]
})]

pd/.Thread[edges->Range[Length[edges]]]

SetAttributes[p,Orderless]

CF[pd_PD]:=Module[{p,edges},
edges=DeleteDuplicates[List@@((Times@@(pd/.X[i_,j_,k_,l_]:>p[i,k]p[j,l]))//.{
p[a_,m1___,b_]p[b_,m2___,c_]:>p[a,m1,b,m2,c],
p[a_,m1___,b_]p[c_,m2___,b_]:>p[a,m1,b,Sequence@@Reverse[{m2}],c]
})];
pd/.Thread[edges->Range[Length[edges]]]
]

CF[pd=PD[X[h[1],4,v[5],5],X[h[2],6,4,h[1]],X[5,v[5],6,h[2]]]]

Jones[PD[X[6,3,1,4],X[2,5,3,6],X[4,1,5,2]]][q]