Ticket #12090: trac_12090-pseudolines-braid.patch

File trac_12090-pseudolines-braid.patch, 3.0 KB (added by ncohen, 8 years ago)
  • doc/en/reference/plotting/index.rst

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1369409081 -7200
    # Node ID 70cbe0398c9b09b2cc7f14ee7bdef7f8e475304f
    # Parent  a0c4ef907d2d77a277119b8fbd8d46d4869e8645
    Arrangements of pseudolines -- pseudolines use the braid plot
    
    diff --git a/doc/en/reference/plotting/index.rst b/doc/en/reference/plotting/index.rst
    a b  
    22===========
    33
    44.. toctree::
    5    :maxdepth: 2
     5   :maxdepth: 1
    66
    77   sage/plot/plot
    88   sage/plot/graphics
  • sage/geometry/pseudolines.py

    diff --git a/sage/geometry/pseudolines.py b/sage/geometry/pseudolines.py
    a b  
    7575**Felsner's Matrix**
    7676
    7777Felser gave an encoding of an arrangement of pseudolines that takes `n^2` bits
    78 instead of the `n^2log(n)` bits required by the two previous encodings. 
     78instead of the `n^2log(n)` bits required by the two previous encodings.
    7979
    8080Instead of storing the permutation ``[3, 2, 1]`` to remember that line `l_0`
    8181crosses `l_3` then `l_2` then `l_1`, it is sufficient to remember the positions
     
    300300                    if i > 0 and seq[i-1] is not []:
    301301                        i -= 1
    302302                    else:
    303                         i += 1 
     303                        i += 1
    304304                else:
    305305                    i += 1
    306306        else:
     
    438438            ...
    439439            ValueError: There has been a problem while plotting the figure...
    440440        """
    441         x = 1
    442         from sage.plot.line import line
    443         from sage.plot.text import text
    444441
    445         lines = [[(0,self._n-1-i)] for i in range(self._n)]
     442        crossings = []
     443
     444        ends = range(self._n)
    446445
    447446        for i,j in self.transpositions():
    448             iy = lines[i][-1][1]
    449             jy = lines[j][-1][1]
     447            iy = ends[i]
     448            jy = ends[j]
    450449
    451             lines[i].append((x, iy))
    452             lines[j].append((x, jy))
     450            crossings.append(max(jy,iy))
     451
     452            ends[i] = jy
     453            ends[j] = iy
    453454
    454455            if abs(iy-jy) != 1:
    455456                raise ValueError(
    456457                    "There has been a problem while plotting the figure. It "+
    457458                    "seems that the lines are not correctly ordered. Please "+
    458459                    "check the pseudolines modules documentation, there is a "
    459                     +"warning about that. ")
     460                    +"warning about that.")
    460461
    461             lines[i].append((x+2,jy))
    462             lines[j].append((x+2,iy))
    463 
    464             x += 2
    465 
    466         L = line([(1,1)])
    467 
    468         for i, l in enumerate(lines):
    469             l.append((x+2, l[-1][1]))
    470             L += line(l)
    471 
    472             L += text(str(i), (0, l[0][1]+.3), horizontal_alignment="right")
    473             L += text(str(i), (x+2, l[-1][1]+.3), horizontal_alignment="left")
    474 
    475         return L.show(axes = False, **args)
    476 
     462        from sage.plot.braid_plot import braid_plot
     463        braid_plot(self._n, crossings, orientation="left-right").show(**args)
    477464
    478465    def __repr__(self):
    479466        r"""