Exemplo n.º 1
0
def clasp():
    c, d = spherogram.Crossing('c'), spherogram.Crossing('d')
    c[0] = d[1]
    c[1] = d[0]
    d2, d3 = d.crossing_strands()[2], d.crossing_strands()[3]
    c2, c3 = c.crossing_strands()[2], c.crossing_strands()[3]
    return Tangle(2, [c, d], [d2, d3, c3, c2])
Exemplo n.º 2
0
def link_diagram(G):
    face_list = faces(G)
    #print(face_list)
    crossing_dict = {}

    for edge in G.edges:  #create one crossing per edge
        l = label(edge)
        crossing_dict[l] = spherogram.Crossing(l)

    for face in face_list:  #connect along faces
        for n, direction in enumerate(face):
            edge = direction[0]
            next_edge = face[(n + 1) % len(face)][0]
            c = crossing_dict[label(edge)]
            cnext = crossing_dict[label(next_edge)]
            o = open_overposition(c)
            u = open_underposition(cnext)
            #            print('c,o: ')
            #            print(c,o)
            #            print('cnext,u: ')
            #            print(cnext,u)
            c[o] = cnext[u]

    for edge in G.edges:  #switch twisted edges
        c = crossing_dict[label(edge)]
        if edge.twisted:
            c.rotate_by_90()

    return spherogram.Link(crossing_dict.values())
Exemplo n.º 3
0
def petaluma_knot(height_perm):
    size = len(height_perm)
    crossing_dict = {}
    visited_dict = {}
    for i in range(size - 1):
        for j in range(i + 1, size):
            crossing_dict[(i, j)] = sg.Crossing('c' + str(i) + str(j))
            visited_dict[(i, j)] = False
    end_position = 2
    if height_perm[1] < height_perm[0]:
        end_position = 3
    old_crossing = crossing_dict[0, 1]
    visited_dict[0, 1] = True

    for i in range(size):
        for j in strands_to_cross(size, i):
            if (i, j) == (0, 1):
                continue
            a, b = sorted([i, j])  #must be ordered
            next_crossing = crossing_dict[a, b]
            ordered_or_backward = 0
            if i > j:
                ordered_or_backward = 1
            if height_perm[i] < height_perm[
                    j]:  # strand i passes under strand j
                if not visited_dict[a, b]:  #if first time crossing has come up
                    next_crossing[0] = old_crossing[end_position]
                    end_position = 2
                else:  #crossing has been seen before
                    if (
                            b - a
                    ) % 2 == 1:  #strand j should cross strand i right to left
                        next_crossing[2] = old_crossing[end_position]
                        end_position = 0
                    else:  #left to right
                        next_crossing[0] = old_crossing[end_position]
                        end_position = 2
            else:  #strand i passes over strand j
                if not visited_dict[a, b]:
                    next_crossing[1] = old_crossing[end_position]
                    end_position = 3
                else:  #crossing has been seen before
                    if (b - a) % 2 == 1:  #right to left
                        next_crossing[1] = old_crossing[end_position]
                        end_position = 3
                    else:  #left to right
                        next_crossing[3] = old_crossing[end_position]
                        end_position = 1
            visited_dict[a, b] = True
            old_crossing = next_crossing

    first = crossing_dict[0, 1]
    last = crossing_dict[size - 2, size - 1]
    first_open = first.adjacent.index(None)  #last open spot
    last_open = last.adjacent.index(None)
    first[first_open] = last[last_open]
    return sg.Link(crossing_dict.values())
Exemplo n.º 4
0
def unknot_search(num_attempts, backtrack_height, num_mutations):
    c = spherogram.Crossing(0)
    c[0] = c[1]
    c[2] = c[3]
    U = spherogram.Link([c])
    for i in range(num_attempts):
        print(i)
        Uc = U.copy()
        Uc.backtrack(backtrack_height)
        for i in range(num_mutations):
            Uc = random_mutate(Uc)
        Uc.simplify(mode='level')
        if len(Uc) > 0:
            return Uc
    return None
Exemplo n.º 5
0
def add_random_crossing(self,label):
    tangle_copy = self.copy()
    adj = tangle_copy.adjacent
    adj[len(adj)/2:] = reversed(adj[len(adj)/2:])
    new_crossing = spherogram.Crossing(label)
    old_position = randint(0,len(adj)-1)
    old_crossing, old_strand = adj.pop(old_position)
    new_strand = randint(0,3)
    old_crossing[old_strand]=new_crossing[new_strand]
    for i in range(1,4):
        adj.insert(old_position,(new_crossing,(new_strand-i)%4))
    adj[len(adj)/2:] = reversed(adj[len(adj)/2:])    
    tangle_copy.crossings.append(new_crossing)
    tangle_copy.n = self.n+1
    return tangle_copy
Exemplo n.º 6
0
v = Kc.exterior().volume()
G = K.dual_graph()
cycle = max(cycle_basis(G),key=len)
T1, T2, gluings = tangle_neighborhood(Kc,c,1)
print(gluings)
"""
v1 = T1.circular_sum(T1,0).exterior().volume()
v2 = T2.circular_sum(T2,0).exterior().volume()
avg_vol = v1/2+v2/2
tsums = T1.all_circular_sums(T2)
vols = map(lambda x: x.exterior().volume(), tsums)

print(v,avg_vol)
"""

a,b,c,d,e,f,g,h = [spherogram.Crossing(x) for x in 'abcdefgh']
a[0]=e[2]
a[1]=b[3]
a[3]=e[3]
b[0]=f[2]
b[1]=c[3]
b[2]=c[2]
c[0]=g[2]
c[1]=d[3]
d[0]=h[2]
d[1]=h[1]
e[1]=f[3]
f[0]=g[0]
f[1]=g[3]
g[1]=h[3]
crossings = [a,b,c,d,e,f,g,h]
Exemplo n.º 7
0
    def setUp(self):
        # Trefoil
        a = spherogram.Crossing('a')
        b = spherogram.Crossing('b')
        c = spherogram.Crossing('c')
        a[2] = b[1]
        b[3] = c[0]
        c[2] = a[1]
        a[3] = b[0]
        b[2] = c[1]
        c[3] = a[0]
        self.Tref = spherogram.Link([a, b, c])

        self.K3_1 = spherogram.Link('3_1')
        self.K7_2 = spherogram.Link('7_2')
        self.K8_3 = spherogram.Link('8_3')
        self.K8_13 = spherogram.Link('8_13')

        # Hopf Link
        a = spherogram.Crossing('a')
        b = spherogram.Crossing('b')
        a[0] = b[1]
        a[1] = b[0]
        a[2] = b[3]
        a[3] = b[2]
        self.L2a1 = spherogram.Link([a, b])

        # Borromean Link (3)
        a = spherogram.Crossing('a')
        b = spherogram.Crossing('b')
        c = spherogram.Crossing('c')
        d = spherogram.Crossing('d')
        e = spherogram.Crossing('e')
        f = spherogram.Crossing('f')
        a[2] = f[1]
        a[3] = e[0]
        b[1] = a[0]
        b[2] = e[3]
        c[0] = a[1]
        c[1] = b[0]
        d[3] = c[2]
        d[0] = b[3]
        e[2] = d[1]
        e[1] = f[0]
        f[2] = c[3]
        f[3] = d[2]
        self.Borr = spherogram.Link([a, b, c, d, e, f])

        self.L6a2 = spherogram.Link('L6a2')
        self.L6a4 = spherogram.Link('L6a4')
        self.L7a3 = spherogram.Link('L7a3')
        self.L10n1 = spherogram.Link('L10n1')

        self.knots = [self.K3_1, self.K7_2, self.K8_3, self.K8_13]
        self.links = [self.L2a1, self.L6a4, self.L6a2, self.L7a3, self.L10n1]
        self.all_links = self.knots + self.links