-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecomposeknotsigs.py
More file actions
50 lines (40 loc) · 1.45 KB
/
decomposeknotsigs.py
File metadata and controls
50 lines (40 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""
Iterate through a collection of knots, given by knot signatures, and attempt
to decompose each knot into prime summands.
"""
from sys import argv, stdout
from regina import *
from experiment import runDecompositionExperiment
def decomposeKnotSigs(dataset):
"""
Decomposes the knots represented by the knot signatures in the given
dataset.
This routine uses the readKnotSigs routine to extract knots from the
given dataset, so the format of the dataset must adhere to the
specifications stated in the documentation for readKnotSigs().
This routine prints the results of each decomposition to standard output.
"""
print()
print( "+-------------------+" )
print( "| Factorising knots |" )
print( "+-------------------+" )
print()
stdout.flush()
slowCoefficient = 2
runDecompositionExperiment(
readKnotSigs(dataset), slowCoefficient )
return
def readKnotSigs(dataset):
"""
Reads knots from the given dataset of knot signatures.
The given dataset should be the name of a text file with one knot
signature per line.
For each knot signature S in the given dataset, this routine yields the
pair (S, K), where K is the knot diagram constructed from S.
"""
with open( dataset, "r" ) as lines:
for sigline in lines:
sig = sigline.rstrip()
yield ( sig, Link.fromKnotSig(sig) )
if __name__ == "__main__":
decomposeKnotSigs( argv[1] )