Example #1
0
def example_3_1b():
    ''' Nathans origional version. '''
    T = flipper.create_triangulation([[1, 2, 5], [0, 6, 3], [4, ~1, 7],
                                      [~3, 8, ~2], [9, ~5, ~6], [10, ~0, ~9],
                                      [~10, ~7, ~8], [11, 12, ~4],
                                      [~12, 14, 13], [~13, ~11, ~14]])

    a = T.lamination([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1])
    b = T.lamination([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1])
    c = T.lamination([0, 1, 1, 0, 2, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1])
    d = T.lamination([0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0])
    e = T.lamination([1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0])
    f = T.lamination([0, 1, 1, 1, 2, 0, 1, 1, 0, 1, 1, 2, 2, 2, 2])
    g = T.lamination([0, 1, 1, 1, 0, 2, 1, 1, 2, 1, 1, 0, 0, 0, 0])
    h = T.lamination([0, 1, 2, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0])

    return flipper.kernel.EquippedTriangulation(T, [a, b, c, d, e, f, g, h], [
        a.encode_twist(),
        b.encode_twist(),
        c.encode_twist(),
        d.encode_twist(),
        e.encode_twist(),
        f.encode_twist(),
        g.encode_twist(),
        h.encode_twist()
    ])
Example #2
0
def example_3_1():
    T = flipper.create_triangulation([[0, 6, 1], [7, ~6, ~5], [8, 2, ~7],
                                      [9, ~8, ~4], [10, 3, ~9], [11, ~10, ~3],
                                      [12, 4, ~11], [13, ~12, ~2],
                                      [14, 5, ~13], [~0, ~14, ~1]])

    a = T.lamination([0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1])
    b = T.lamination([0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0])
    c = T.lamination([0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0])
    d = T.lamination([0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0])
    e = T.lamination([0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0])
    f = T.lamination([1, 1, 1, 0, 1, 1, 2, 1, 0, 1, 1, 1, 2, 1, 0])
    g = T.lamination([1, 1, 1, 0, 1, 1, 0, 1, 2, 1, 1, 1, 0, 1, 2])
    h = T.lamination([1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 2])

    return flipper.kernel.EquippedTriangulation(T, [a, b, c, d, e, f, g, h], [
        a.encode_twist(),
        b.encode_twist(),
        c.encode_twist(),
        d.encode_twist(),
        e.encode_twist(),
        f.encode_twist(),
        g.encode_twist(),
        h.encode_twist()
    ])
Example #3
0
def example_24():
    # A 24-gon.
    T = flipper.create_triangulation([[12, 13, 0], [14, 1, ~13], [15, 2, ~14],
                                      [~15, 16, 3], [17, 4, ~16], [~17, 18, 5],
                                      [~18, 19, 6], [20, 7, ~19], [21, 8, ~20],
                                      [~21, 22, 9], [~22, 23, 10],
                                      [24, 11, ~23], [25, ~0, ~24],
                                      [~25, 26, ~1], [~26, 27, ~2],
                                      [28, ~3, ~27], [29, ~4, ~28],
                                      [~29, 30, ~5], [~30, 31, ~6],
                                      [32, ~7, ~31], [33, ~8, ~32],
                                      [~33, 34, ~9], [~34, 35, ~10],
                                      [~12, ~11, ~35]])

    a = T.lamination([
        0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
    ])
    b = T.lamination([
        0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0
    ])
    p = T.find_isometry(T, {13: ~12})  # This is a 1/24 click.

    return flipper.kernel.EquippedTriangulation(T, [a, b], {
        'a': a.encode_twist(),
        'b': b.encode_twist(),
        'p': p.encode()
    })
Example #4
0
def example_1_1():
    T = flipper.create_triangulation([[0, 2, 1], [~0, ~2, ~1]])

    a = T.lamination([1, 0, 1])
    b = T.lamination([0, 1, 1])

    return flipper.kernel.EquippedTriangulation(
        T, [a, b], [a.encode_twist(), b.encode_twist()])
Example #5
0
def example_1_1m():
    # Mirror image of S_1_1 and its standard (Twister) curves:
    T = flipper.create_triangulation([[0, 1, 2], [~0, ~1, ~2]])

    a = T.lamination([1, 1, 0])
    b = T.lamination([0, 1, 1])

    return flipper.kernel.EquippedTriangulation(
        T, [a, b], [a.encode_twist(), b.encode_twist()])
Example #6
0
def example_1_2p():
    # S_1_2 without the half twist
    T = flipper.create_triangulation([[1, 3, 2], [~2, 0, 4], [~1, 5, ~0],
                                      [~5, ~4, ~3]])

    a = T.lamination([0, 0, 1, 1, 1, 0])
    b = T.lamination([1, 0, 0, 0, 1, 1])
    c = T.lamination([0, 1, 0, 1, 0, 1])

    return flipper.kernel.EquippedTriangulation(
        T, [a, b, c], [a.encode_twist(),
                       b.encode_twist(),
                       c.encode_twist()])
Example #7
0
def example_braid_sphere(n):
    # A triangulation of S_{0,n}.
    assert (isinstance(n, flipper.IntegerType))
    assert (n >= 4)

    # We'll build the following triangulation of S_{0,n}:
    #
    # |      |      |      |       |
    # |0     |1     |2     |3      |n-3
    # |      |      |      |       |
    # | 2n-4 | 2n-3 | 2n-2 |       | 3n-7
    # X------X------X------X- ... -X------X
    #        |      |      |       |      |
    #        |      |      |       |      |
    #        |n-2   |n-1   |n      |2n-6  |2n-5
    #        |      |      |       |      |
    #
    # Note that there puncture 1 is not shown here and is on the "boundary" of the disk.
    # There are two families of triangles on the top and the bottom and two exceptional cases:
    #  1) Top triangles are given by [i, i+2n-4, ~(i+1)] for i in range(0, n-3)],
    #  2) Bottom triangles are given by [i, ~(i+1), ~(i+n-1)] for i in range(n-2, 2n-5),
    #  3) Left triangle given by [~0, ~(n-2), ~(2n-4)], and
    #  4) Right triangle given by [n-3, 3n-7, 2n-5].
    T = flipper.create_triangulation(
        [[i, i + 2 * n - 4, ~(i + 1)]
         for i in range(0, n - 3)] + [[i, ~(i + 1), ~(i + n - 1)]
                                      for i in range(n - 2, 2 * n - 5)] +
        [[~0, ~(n - 2), ~(2 * n - 4)], [n - 3, 3 * n - 7, 2 * n - 5]])

    # We'll then create a curve isolating the ith and (i+1)st punctures from the others.
    # There are four special cases and a generic case:
    #  0) A curve isolating punctures 1 & 2, meeting edges 1, 2, ..., n-3, n-2, n-1, ..., 2n-5, 2n-4,
    #  1) A curve isolating punctures 2 & 3, meeting edges 0, 1, n-2 and 2n-3,
    #  2) A curve isolating punctures i & i+1, meeting edges i, i+1, i+n-3, i+n-2, i+2n-5 and i+2n-3,
    #  3) A curve isolating punctures n-1 & n, meeting edges n-3, 2n-6, 2n-5 and 3n-7, and
    #  4) A curve isolating punctures n & 1, meeting edges 0, 1, ..., n-3, n-2, n-1, ..., 2n-6, 3n-7.

    laminations = \
        [T.lamination([1 if 1 <= j <= 2 * n - 4 else 0 for j in range(T.zeta)])] + \
        [T.lamination([1 if j in [0, 1, n-2, 2*n - 3] else 0 for j in range(T.zeta)])] + \
        [T.lamination([1 if j in [i, i+1, i+n-3, i+n-2, i+2*n-5, i+2*n-3] else 0 for j in range(T.zeta)]) for i in range(1, n-3)] + \
        [T.lamination([1 if j in [n-3, 2*n - 6, 2*n - 5, 3*n - 8] else 0 for j in range(T.zeta)])] + \
        [T.lamination([1 if 0 <= j <= 2 * n - 6 or j == 3*n - 7 else 0 for j in range(T.zeta)])]

    # We take the half-twist about each of these curves as the generator \sigma_i of SB_n.
    mapping_classes = dict(('s_%d' % index, lamination.encode_halftwist())
                           for index, lamination in enumerate(laminations))

    return flipper.kernel.EquippedTriangulation(T, laminations,
                                                mapping_classes)
Example #8
0
    def flipper_triangulation(self):
        """ Return this surface as a flipper triangulation. """

        data = self.triangulation_data()

        edges = sorted({d.edge_name for d in data})  # Remove duplicates.
        edge_lookup = dict((edge, index) for index, edge in enumerate(edges))

        ans = [
            tuple(edge_lookup[datum.edge_name] if datum.sign ==
                  +1 else ~edge_lookup[datum.edge_name] for datum in x)
            for x in zip(data[::3], data[1::3], data[2::3])
        ]
        return flipper.create_triangulation(ans)
Example #9
0
def example_0_4():
    T = flipper.create_triangulation([[0, 3, ~0], [1, 4, ~3], [~1, ~4, 5],
                                      [~2, ~5, 2]])

    a = T.lamination([0, 1, 0, 0, 1, 0])
    b = T.lamination([1, 0, 1, 2, 2, 2])

    return flipper.kernel.EquippedTriangulation(
        T, [a, b], {
            'a': a.encode_twist(),
            'b': b.encode_twist(),
            'w': a.encode_halftwist(),
            'x': b.encode_halftwist(),
            'y': a.encode_halftwist(),
            'z': b.encode_halftwist()
        })
Example #10
0
def example_12():
    # A 12-gon:
    T = flipper.create_triangulation([[6, 7, 0], [8, 1, ~7], [~8, 9, 2],
                                      [~9, 10, 3], [11, 4, ~10], [12, 5, ~11],
                                      [~12, 13, ~0], [14, ~1, ~13],
                                      [~14, 15, ~2], [~15, 16, ~3],
                                      [~16, 17, ~4], [~6, ~5, ~17]])

    a = T.lamination([1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0])
    b = T.lamination([1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0])
    p = T.find_isometry(T, {7: ~6})  # This is a 1/12 click.

    return flipper.kernel.EquippedTriangulation(T, [a, b], {
        'a': a.encode_twist(),
        'b': b.encode_twist(),
        'p': p.encode()
    })
Example #11
0
def example_4_1():
    T = flipper.create_triangulation([[~8, 1, 2], [3, 4, ~9], [6, ~10, 5],
                                      [~0, ~11, 7], [~12, ~1,
                                                     ~2], [~13, ~3, ~4],
                                      [~14, ~5, ~6], [~15, ~7, 0], [8, 9, ~16],
                                      [11, ~17, 10], [13, ~18, 12],
                                      [~19, 14, 15], [~20, 16, 17],
                                      [18, 19, 20]])

    a = T.lamination(
        [0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 2])
    b = T.lamination(
        [0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 2])
    c = T.lamination(
        [0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 2])
    d = T.lamination(
        [0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 2])
    e = T.lamination(
        [0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 2])
    f = T.lamination(
        [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1])
    g = T.lamination(
        [0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1])
    h = T.lamination(
        [1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 2, 2, 2, 1, 0, 0, 1, 2, 1, 0, 1])
    i = T.lamination(
        [1, 1, 1, 1, 0, 1, 1, 1, 2, 1, 0, 0, 0, 1, 2, 2, 1, 0, 1, 2, 1])
    j = T.lamination(
        [1, 1, 1, 1, 0, 0, 1, 1, 2, 1, 1, 0, 0, 1, 1, 2, 1, 1, 1, 1, 2])

    return flipper.kernel.EquippedTriangulation(T,
                                                [a, b, c, d, e, f, g, h, i, j],
                                                [
                                                    a.encode_twist(),
                                                    b.encode_twist(),
                                                    c.encode_twist(),
                                                    d.encode_twist(),
                                                    e.encode_twist(),
                                                    f.encode_twist(),
                                                    g.encode_twist(),
                                                    h.encode_twist(),
                                                    i.encode_twist(),
                                                    j.encode_twist()
                                                ])
Example #12
0
def example_2_1():
    # S_2_1 and its standard (Twister) curves:
    T = flipper.create_triangulation([[0, 4, 1], [5, ~4, ~3], [2, ~5, 6],
                                      [7, ~6, ~2], [3, ~7, 8], [~0, ~8, ~1]])

    a = T.lamination([0, 1, 1, 0, 1, 1, 2, 1, 1])
    b = T.lamination([0, 1, 0, 1, 1, 0, 0, 0, 1])
    c = T.lamination([1, 0, 0, 1, 1, 0, 0, 0, 1])
    d = T.lamination([0, 1, 1, 1, 1, 0, 1, 2, 1])
    e = T.lamination([0, 1, 1, 1, 1, 2, 1, 0, 1])
    f = T.lamination([0, 0, 1, 0, 0, 0, 1, 0, 0])

    return flipper.kernel.EquippedTriangulation(T, [a, b, c, d, e, f], [
        a.encode_twist(),
        b.encode_twist(),
        c.encode_twist(),
        d.encode_twist(),
        e.encode_twist(),
        f.encode_twist()
    ])
Example #13
0
def example_2_1b():
    ''' Nathans origional version. '''
    T = flipper.create_triangulation([[1, 2, 4], [5, 3, 0], [~2, 6, ~1],
                                      [~3, ~0, 7], [~4, ~5, 8], [~7, ~8, ~6]])

    a = T.lamination([0, 1, 1, 0, 0, 0, 0, 0, 0])
    b = T.lamination([0, 0, 1, 0, 1, 0, 1, 0, 1])
    c = T.lamination([1, 0, 0, 0, 0, 1, 0, 1, 1])
    d = T.lamination([0, 1, 1, 1, 0, 1, 2, 1, 1])
    e = T.lamination([0, 1, 1, 1, 2, 1, 0, 1, 1])
    f = T.lamination([0, 1, 2, 1, 1, 1, 1, 1, 0])

    return flipper.kernel.EquippedTriangulation(T, [a, b, c, d, e, f], [
        a.encode_twist(),
        b.encode_twist(),
        c.encode_twist(),
        d.encode_twist(),
        e.encode_twist(),
        f.encode_twist()
    ])
Example #14
0
def example_36():
    # A 36-gon
    T = flipper.create_triangulation([[18, 19, 0], [20, 1, ~19], [21, 2, ~20],
                                      [~21, 22, 3], [~22, 23, 4], [24, 5, ~23],
                                      [25, 6, ~24], [~25, 26, 7], [27, 8, ~26],
                                      [~27, 28, 9], [~28, 29, 10],
                                      [30, 11, ~29], [31, 12, ~30],
                                      [~31, 32, 13], [~32, 33, 14],
                                      [34, 15, ~33], [35, 16, ~34],
                                      [~35, 36, 17], [~36, 37, ~0],
                                      [38, ~1, ~37], [39, ~2, ~38],
                                      [~39, 40, ~3], [~40, 41, ~4],
                                      [42, ~5, ~41], [43, ~6, ~42],
                                      [~43, 44, ~7], [~44, 45, ~8],
                                      [46, ~9, ~45], [47, ~10, ~46],
                                      [~47, 48, ~11], [~48, 49, ~12],
                                      [50, ~13, ~49], [51, ~14, ~50],
                                      [~51, 52, ~15], [~52, 53, ~16],
                                      [~18, ~17, ~53]])

    a = T.lamination([
        1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0
    ])
    b = T.lamination([
        0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0
    ])
    p = T.find_isometry(T, {19: ~18})  # This is a 1/36 click.

    return flipper.kernel.EquippedTriangulation(T, [a, b], {
        'a': a.encode_twist(),
        'b': b.encode_twist(),
        'p': p.encode()
    })
Example #15
0
def example_1_2():
    # S_1_2 and its standard (Twister) curves:
    T = flipper.create_triangulation([[1, 3, 2], [~2, 0, 4], [~1, 5, ~0],
                                      [~5, ~4, ~3]])

    a = T.lamination([0, 0, 1, 1, 1, 0])
    b = T.lamination([1, 0, 0, 0, 1, 1])
    c = T.lamination([0, 1, 0, 1, 0, 1])
    x = T.lamination([2, 0, 2, 2, 2, 2])

    return flipper.kernel.EquippedTriangulation(
        T, {
            'a': a,
            'b': b,
            'c': c,
            'x': x
        }, {
            'a': a.encode_twist(),
            'b': b.encode_twist(),
            'c': c.encode_twist(),
            'x': T.encode([{
                0: ~2
            }, 4, 5, 2, 3, 0, 4, 2])
        })
Example #16
0
def LP(genus, num_punctures):
    g = int(genus)
    n = int(num_punctures)

    # The following functions make edge labelling easier.
    # In the picture of the triangulation in documentation, some edges are labelled with colored numbers.
    # The below function convert these coloured numbers to indices.
    # For example, if an edge of the triangulation is labelled 5 and colored green then its index is 5+2*g (or 2 if g = 1).

    green = lambda m: m + 2 * g if g > 1 else 2
    pink = lambda m: m + 4 * g if g > 2 else 8
    blue = lambda m: m + 5 * g
    orange = lambda m: m + 6 * g - 3

    empty_lam = lambda: [0 for i in range(6 * g + 3 * n - 6)]

    if g == 0:
        triangles = [(3 * i, 3 * i + 2, ~(3 * ((i + 1) % (n - 2))))
                     for i in range(n - 2)] + [(3 * i + 1, ~(3 * (
                         (i + 1) % (n - 2)) + 1), ~(3 * i + 2))
                                               for i in range(n - 2)]

        lams = dict()
        for i in range(n):
            lams['q' + str(i)] = empty_lam()
        for j in range(3, 3 * n - 8, 3) + [1, 2, 3 * n - 7]:
            lams['q0'][j] += 1
        for j in range(3, 6) + [0, 1, 3 * n - 7]:
            lams['q1'][j] += 1
        for i in range(0, n - 4):
            for j in range(3 * i + 2, 3 * i + 5) + range(3 * i + 6, 3 * i + 9):
                lams['q' + str(i + 2)][j] += 1
        for j in range(1, 3 * n - 8, 3) + [3 * n - 10, 3 * n - 9, 3 * n - 7]:
            lams['q' + str(n - 2)][j] += 1
        for j in range(1, 3 * n - 7, 3) + range(0, 3 * n - 8,
                                                3) + [3 * n - 7, 3 * n - 7]:
            lams['q' + str(n - 1)][j] += 1
    else:
        if g >= 1:
            triangles = [
                (k, k + 1, green(k)) for k in range(0, 2 * g - 1, 2)
            ] + [(~k, ~(k + 1), ~green(k + 1)) for k in range(0, 2 * g - 1, 2)]
        if g > 2:
            triangles += [(~green(k), green(k + 1), ~pink(k / 2))
                          for k in range(0, 2 * g - 1, 2)]
        if g == 2:
            triangles += [(~green(0), green(1), ~pink(0)),
                          (~green(2), green(3), pink(0))]
        if g == 3:
            triangles += [(pink(0), pink(1), pink(2))]
        if g > 3:
            triangles += [
                (blue(k), pink(k + 2), ~blue(k + 1)) for k in range(0, g - 4)
            ] + [(pink(0), pink(1), ~blue(0)),
                 (pink(g - 2), pink(g - 1), blue(g - 4))]

        if n == 2:  # For n == 2 we need a certain triangulation, so we can more easily compute the halftwist in terms of flips later.
            triangles.remove((2 * g - 2, 2 * g - 1, green(2 * g - 2)))
            triangles += [(orange(0), ~orange(2), orange(2)),
                          (2 * g - 2, ~orange(0), orange(1)),
                          (green(2 * g - 2), ~orange(1), 2 * g - 1)]
        if n > 2:
            triangles.remove((2 * g - 2, 2 * g - 1, green(2 * g - 2)))
            triangles += [(2 * g - 2, orange(0), orange(1)),
                          (green(2 * g - 2), ~orange(3 * n - 5),
                           orange(3 * n - 4)),
                          (2 * g - 1, ~orange(3 * n - 4), ~orange(3 * n - 6))]
            triangles += [(~orange(k), orange(k + 3), ~orange(k + 2))
                          for k in range(0, 3 * n - 8, 3)
                          ] + [(~orange(k + 1), orange(k + 2), orange(k + 4))
                               for k in range(0, 3 * n - 8, 3)]

        lams = dict()
        if g == 1:
            lams['a0'] = empty_lam()
            lams['a0'][1] += 1
            lams['a0'][green(0)] += 1
            lams['b0'] = empty_lam()
            lams['b0'][0] += 1
            lams['b0'][green(0)] += 1
        elif g > 1:
            for i in [0, 1]:
                lams['a' + str(i)] = empty_lam()
                for j in [2 * i + 1, green(2 * i), green(2 * i + 1)]:
                    lams['a' + str(i)][j] += 1
            for i in range(g):
                lams['b' + str(i)] = empty_lam()
                for j in [2 * i, green(2 * i), green(2 * i + 1)]:
                    lams['b' + str(i)][j] += 1
        if g == 2:
            lams['c0'] = empty_lam()
            for j in [
                    1,
                    green(0),
                    pink(0),
                    green(2), 2,
                    green(3),
                    green(2), 3, 2,
                    green(2),
                    pink(0),
                    green(1)
            ]:
                lams['c0'][j] += 1
        elif g > 2:
            for i in range(g - 1):
                lams['c' + str(i)] = empty_lam()
                for j in [
                        2 * i + 1,
                        green(2 * i),
                        pink(i),
                        pink(i + 1),
                        green(2 * i + 2), 2 * i + 2,
                        green(2 * i + 3),
                        green(2 * i + 2), 2 * i + 3, 2 * i + 2,
                        green(2 * i + 2),
                        pink(i + 1),
                        pink(i),
                        green(2 * i + 1)
                ]:
                    lams['c' + str(i)][j] += 1
            for i in range(1, g - 2):
                lams['c' + str(i)][blue(i - 1)] += 2
        if n == 2:
            lams['b' + str(g - 1)][orange(1)] += 1
            if 'c' + str(g - 2) in lams.keys():
                lams['c' + str(g - 2)][orange(1)] += 2
            lams['p0'] = empty_lam()
            for j in [
                    2 * g - 1,
                    green(2 * g - 1),
                    green(2 * g - 2),
                    orange(0),
                    orange(0),
                    orange(1),
                    orange(1),
                    orange(2)
            ]:
                lams['p0'][j] += 1
            if g == 1:
                for i in range(n - 1):
                    lams['p' + str(i)][green(2 * g - 1)] -= 1
            lams['q0'] = [2 for i in range(6 * g + 3 * n - 6)]
            lams['q0'][orange(0)] -= 2
            lams['q0'][orange(2)] -= 2
        if n > 2:
            if 'a' + str(g - 1) in lams.keys():
                lams['a' + str(g - 1)][orange(3 * n - 4)] += 1
            for j in [orange(3 * k + 1) for k in range(n - 1)]:
                lams['b' + str(g - 1)][j] += 1
            if 'c' + str(g - 2) in lams.keys():
                for j in [orange(3 * n - 4)] + [
                        orange(3 * k + 1) for k in range(n - 1)
                ] + [orange(3 * k + 1) for k in range(n - 1)]:
                    lams['c' + str(g - 2)][j] += 1
            lams['p0'] = empty_lam()
            for j in [2 * g - 1, green(2 * g - 1),
                      green(2 * g - 2)] + [
                          orange(3 * k) for k in range(n - 1)
                      ] + [orange(3 * k + 1) for k in range(n - 1)]:
                lams['p0'][j] += 1
            for i in range(1, n - 1):
                lams['p' + str(i)] = empty_lam()
                for j in [
                        2 * g - 1,
                        green(2 * g - 1),
                        green(2 * g - 2),
                        orange(3 * i - 1)
                ] + [orange(3 * k) for k in range(i, n - 1)
                     ] + [orange(3 * k + 1) for k in range(i, n - 1)]:
                    lams['p' + str(i)][j] += 1
            if g == 1:
                for i in range(n - 1):
                    lams['p' + str(i)][green(2 * g - 1)] -= 1

            lams['q0'] = [2 for i in range(6 * g + 3 * n - 6)]
            for j in [orange(3 * k + 2)
                      for k in range(1, n - 2)] + [orange(0)]:
                lams['q0'][j] -= 2
            for j in [orange(3 * k) for k in range(1, n - 1)] + [
                    orange(3 * k + 1) for k in range(1, n - 1)
            ] + [orange(2), orange(3 * n - 4)]:
                lams['q0'][j] -= 1

            lams['q1'] = empty_lam()
            for j in [orange(0), orange(1), orange(3), orange(4), orange(5)]:
                lams['q1'][j] += 1
            for i in range(2, n - 1):
                lams['q' + str(i)] = empty_lam()
                for j in [
                        orange(3 * (i - 1) - 1),
                        orange(3 * (i - 1)),
                        orange(3 * (i - 1) + 1),
                        orange(3 * (i - 1) + 3),
                        orange(3 * (i - 1) + 4),
                        orange(3 * (i - 1) + 5)
                ]:
                    lams['q' + str(i)][j] += 1

    triangulation = flipper.create_triangulation(triangles)

    # Below we compute the halftwist around the isolating curve bounding the two punctures, for the n == 2 case, in terms of flips.
    # We then relable the edges, and re-create the triangulation, since we have altered the original one in the process of finding the flips.
    if n == 2:

        def _edges_around_vert(t, vert):
            """ Return the cyclically ordered list of edges around the given vertex.
            
            Vertex is input as an int corresponding to its index.
            That is, for vertex "Puncture 0", do edges_around_vert(t, 0). """

            crns = t.corner_class_of_vertex(t.vertices[vert])
            edges = [crns[i].edges[1].label for i in range(len(crns))]
            edges.reverse()
            return edges

        t = triangulation
        seq = []
        vert = 0 if len(_edges_around_vert(t, 0)) > 1 else 1
        edges = _edges_around_vert(t, vert)
        fixed_edge = orange(2) if orange(2) in edges else ~orange(2)
        ind = edges.index(fixed_edge)
        edges_0 = [edges[(ind + i) % len(edges)] for i in range(len(edges))]
        while len(edges) > 1:
            ind = (edges.index(fixed_edge) + 1) % len(edges)
            seq.append(edges[ind])
            t = t.flip_edge(edges[ind])
            edges = _edges_around_vert(t, vert)
        edges = _edges_around_vert(t, (vert + 1) % 2)
        ind = edges.index(~fixed_edge)
        edges = [edges[(ind + i) % len(edges)] for i in range(len(edges))]
        isom = dict(zip(edges, edges_0))
        seq.append(isom)
        seq.reverse()
        triangulation = flipper.create_triangulation(triangles)
        isolating_halftwist = triangulation.encode(seq)

    laminations = dict([(key, triangulation.lamination(value))
                        for key, value in lams.items()])

    twists = dict()
    halftwists = dict()

    # If n == 2 then we have to add the halftwist (created above from flips) seperately.
    # It seems that the halftwist computed above is actually the right Dehn twist (based on the check below using chain relation).
    # So it is called 'Q0' and its inverse is 'q0' (lower case indicates left twists, upper case right twists).
    if n == 2:
        # halftwists['Q0'] = isolating_halftwist
        halftwists['q0'] = isolating_halftwist.inverse()

    for key in lams.keys():
        if key == 'q0' and n == 2:
            pass
        elif key[0] == 'q':
            halftwists[key] = laminations[key].encode_halftwist(1)
            # halftwists[key.upper()] = laminations[key].encode_halftwist(-1)
        else:
            twists[key] = laminations[key].encode_twist(1)
            # twists[key.upper()] = laminations[key].encode_twist(-1)
    all_twists = dict([(key, value) for key, value in twists.items()] +
                      [(key, value) for key, value in halftwists.items()])

    return flipper.kernel.EquippedTriangulation(triangulation, laminations,
                                                all_twists)
Example #17
0
def example_5_1():
    T = flipper.create_triangulation([[~10, 1, 2], [~11, 3, 4], [6, ~12, 5],
                                      [7, 8, ~13], [~0, ~14, 9], [~2, ~15, ~1],
                                      [~4, ~16, ~3], [~6, ~17, ~5],
                                      [~8, ~18, ~7], [0, ~19, ~9],
                                      [11, ~20, 10], [12, 13, ~21],
                                      [15, ~22, 14], [~23, 16, 17],
                                      [19, ~24, 18], [20, 21, ~25],
                                      [~26, 22, 23], [24, 25, 26]])

    a = T.lamination([
        0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0,
        1, 1, 0
    ])
    b = T.lamination([
        0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0,
        1, 1, 0
    ])
    c = T.lamination([
        0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0,
        1, 2, 1
    ])
    d = T.lamination([
        0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1,
        1, 2, 1
    ])
    e = T.lamination([
        0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1,
        1, 2, 1
    ])
    f = T.lamination([
        0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1,
        1, 2, 1
    ])
    g = T.lamination([
        0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 2,
        0, 2, 2
    ])
    h = T.lamination([
        0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1,
        0, 1, 1
    ])
    i = T.lamination([
        0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1,
        0, 1, 1
    ])
    j = T.lamination([
        1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 2, 2, 2, 2, 1, 0, 0, 0, 1, 2, 1,
        0, 1, 1
    ])
    k = T.lamination([
        1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 2, 2, 1, 0, 0, 0, 0, 1, 2, 2, 2, 1, 0, 1,
        2, 1, 1
    ])
    l = T.lamination([
        1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0,
        2, 2, 0
    ])  # noqa: E741

    return flipper.kernel.EquippedTriangulation(
        T, [a, b, c, d, e, f, g, h, i, j, k, l], [
            a.encode_twist(),
            b.encode_twist(),
            c.encode_twist(),
            d.encode_twist(),
            e.encode_twist(),
            f.encode_twist(),
            g.encode_twist(),
            h.encode_twist(),
            i.encode_twist(),
            j.encode_twist(),
            k.encode_twist(),
            l.encode_twist()
        ])