#17030: Knot Theory as a part of GSoC 2014.
-------------------------------------+-------------------------------------
       Reporter:  amitjamadagni      |        Owner:  amitjamadagni
           Type:  enhancement        |       Status:  needs_work
       Priority:  major              |    Milestone:  sage-6.9
      Component:  algebraic          |   Resolution:
  topology                           |    Merged in:
       Keywords:                     |    Reviewers:  Miguel Marco, Karl-
        Authors:  Amit Jamadagni,    |  Dieter Crisman, Frédéric Chapoton
  Miguel Marco                       |  Work issues:
Report Upstream:  N/A                |       Commit:
         Branch:                     |  cb84cec88f012844ac65d102296644a77f89818c
  public/ticket/17030                |     Stopgaps:
   Dependencies:                     |
-------------------------------------+-------------------------------------

Comment (by jhpalmieri):

 Hi Travis,

 Please go ahead with a full review. I think a new `Knot` class would be
 good. For future work, it would also be nice to have a catalog of links
 and knots (e.g., `knots.Trefoil()`) and also ways of producing new links
 from old. Could you add a `.. todo` list?

 I agree that more documentation would be great, with definitions,
 references, and (for `plot` at least) algorithms.

 How is equality determined? How should it be? Should the oriented Gauss
 code be good enough?
 {{{
 sage: trefoil = Link([[1, 5, 2, 4], [5, 3, 6, 2], [3, 1, 4, 6]])
 sage: trefoil == Link([[1, 5, 2, 4], [5, 3, 6, 2], [3, 1, 4, 6]])
 False
 }}}

 I haven't actually looked at the code, and I don't know if I ever will.
 Some suggestions for miscellaneous minor cleanup:
 {{{
 #!diff
 diff --git a/src/sage/knots/link.py b/src/sage/knots/link.py
 index 04facf8..89f9624 100644
 --- a/src/sage/knots/link.py
 +++ b/src/sage/knots/link.py
 @@ -10,7 +10,7 @@ A link is an embedding of one or more copies of
 `\\mathbb{S}^1` in `\\mathbb{S}^
  considered up to ambient isotopy. That is, a link represents the idea of
 one or more
  tied ropes. Every knot is a link, but not every link is a knot.

 -Generically, the projection of a link on `\\mathbb{R}^2`
 +Generically, the projection of a link to `\\Bold{R}^2`
  is a curve with crossings. The crossings are represented to show which
 strand goes
  over the other. This curve is called a planar diagram of the link. If we
 remove the
  crossings, the resulting connected components are segments. These
 segments are
 @@ -40,16 +40,12 @@ AUTHORS:

  from sage.matrix.constructor import matrix
  from sage.rings.integer_ring import ZZ
 -from sage.rings.polynomial.polynomial_ring_constructor import
 PolynomialRing
  from sage.rings.finite_rings.integer_mod import Mod
  from sage.graphs.digraph import DiGraph
  from sage.graphs.graph import Graph
  from copy import deepcopy, copy
  from sage.rings.polynomial.laurent_polynomial_ring import
 LaurentPolynomialRing
 -from sage.rings.integer_ring import IntegerRing
 -from sage.combinat.permutation import Permutations
 -from sage.rings.finite_rings.integer_mod_ring import IntegerModRing
 -from sage.symbolic.ring import SR, var
 +from sage.symbolic.ring import SR
  from sage.rings.integer import Integer
  from sage.numerical.mip import MixedIntegerLinearProgram
  from sage.functions.generalized import sign
 @@ -74,7 +70,7 @@ class Link:
          sage: L
          Link with 2 components represented by 5 crossings

 -    Note that the strands of the braid that have no crossings at all are
 ignored.
 +      Note that the strands of the braid that have no crossings at all
 are ignored.

      - Oriented Gauss Code:

 @@ -82,7 +78,7 @@ class Link:
        crossings) and start moving along the link. Trace every component
 of
        the link, by starting at a particular point on one component of the
 link and
        writing down each of the crossings that you encounter until
 returning to the starting
 -      point. The crossings are written with sign depending on wheter we
 cross them
 +      point. The crossings are written with sign depending on whether we
 cross them
        as over or undercrossing. Each component is then represented as a
 list whose
        elements are the crossing numbers. A second list of +1 and -1's
 keeps track of
        the orientation of each crossing::
 @@ -91,7 +87,7 @@ class Link:
          sage: L
          Knot represented by 8 crossings

 -      For links there is more than one component and the input is as
 follows::
 +      For links there may be more than one component and the input is as
 follows::

          sage: L = Link([[[-1, 2], [-3, 4], [1, 3, -4, -2]], [-1, -1, 1,
 1]])
          sage: L
 @@ -177,15 +173,13 @@ class Link:
                  self._PD_code = None

              else:
 -                raise Exception("Invalid Input: Data must be either a
 list or a Braid")
 +                raise ValueError("Invalid Input: Data must be either a
 list or a Braid")

      def __repr__(self):
          """
          Return a string representation.

 -        OUTPUT:
 -
 -        - A string.
 +        OUTPUT: string representation

          EXAMPLES::

 @@ -211,9 +205,7 @@ class Link:
          """
          Return the braid representation of the link.

 -        OUTPUT:
 -
 -        - Braid representation of the link.
 +        OUTPUT: braid representation of the link

          EXAMPLES::

 @@ -397,7 +389,7 @@ class Link:

          b. The orientation of each crossing

 -        The following orientation was taken into consideration for
 consturction
 +        The following orientation was taken into consideration for
 construction
          of knots:

          From the outgoing of the overcrossing if we move in the clockwise
 direction
 @@ -411,11 +403,9 @@ class Link:
          The order of the orientation is same as the ordering of the
 crossings in the
          gauss code.

 -        Convention : under is denoted by -1, and over by +1 in the
 crossing info.
 +        Convention: under is denoted by -1, and over by +1 in the
 crossing info.

 -        OUTPUT:
 -
 -        - Oriented gauss code of the link
 +        OUTPUT: Oriented gauss code of the link

          EXAMPLES::

 @@ -469,21 +459,19 @@ class Link:

      def PD_code(self):
          """
 -        Return the Planar Diagram code of the link. The Planar Diagram is
 returned
 +        Return the planar diagram code of the link. The planar diagram is
 returned
          in the following format.

          We construct the crossing by starting with the entering component
 of the
          undercrossing, move in the clockwise direction and then generate
 the list.
 -        Suppose if the crossing is given by [a, b, c, d], then we
 interpret this
 -        information as :
 +        If the crossing is given by [a, b, c, d], then we interpret this
 +        information as:

          1. a is the entering component of the undercrossing
          2. b, d are the components of the overcrossing
          3. c is the leaving component of the undercrossing

 -        OUTPUT:
 -
 -        - Planar Diagram representation of the link.
 +        OUTPUT: planar diagram representation of the link.

          EXAMPLES::

 @@ -564,18 +552,16 @@ class Link:

      def gauss_code(self):
          """
 -        Return the gauss_code of the link. Gauss code is generated by the
 +        Return the Gauss code of the link. Gauss code is generated by the
          following procedure:

          a. Number the crossings from 1 to n.
          b. Select a point on the knot and start moving along the
 component.
          c. At each crossing, take the number of the crossing, along with
 -           sign, which is '-' if it is a undercrossing and '+' if it is a
 +           sign, which is '-' if it is an undercrossing and '+' if it is
 an
             overcrossing.

 -        OUTPUT:
 -
 -        - Gauss code representation of the link.
 +        OUTPUT: Gauss code representation of the link

          EXAMPLES::

 @@ -594,7 +580,7 @@ class Link:

      def dt_code(self):
          """
 -        Return the dt_code of the knot. DT code is generated by the
 following way.
 +        Return the DT code of the knot. DT code is generated as follows.

          Start moving along the knot, as we encounter the crossings we
          start numbering them, so every crossing has two numbers assigned
 to
 @@ -605,10 +591,7 @@ class Link:
          Take the even number with a negative sign if it is an
 overcrossing
          that we are encountering.

 -        OUTPUT:
 -
 -        - DT Code representation of the knot. This is implemented only
 -          for knots.
 +        OUTPUT: DT Code representation of the knot. This is implemented
 only for knots.

          EXAMPLES::

 @@ -644,7 +627,7 @@ class Link:
                          crossing = i
                          break
              if(label[2 * crossing + next_label % 2] == 1):
 -                raise Exception("Implemented only for knots")
 +                raise ValueError("Implemented only for knots")
              else:
                  label[2 * crossing + next_label % 2] = next_label
                  next_label = next_label + 1
 @@ -674,15 +657,12 @@ class Link:
      def _dowker_notation_(self):
          """
          Return the dowker notation of the link. Similar to the PD Code we
 number the
 -        components. So every crossing is represented by four numbers. We
 focus on
 -        the incoming entites of the under and the over crossing. It is
 the pair of incoming
 -        under cross and the incoming over cross. This information at
 every cross
 +        components, so every crossing is represented by four numbers. We
 focus on
 +        the incoming entities of the under and the overcrossing. It is
 the pair of incoming
 +        undercross and the incoming overcross. This information at every
 cross
          gives the dowker notation.

 -        OUTPUT:
 -
 -        - List containing the pair of incoming under cross and the
 incoming
 -          over cross.
 +        OUTPUT: List containing the pair of incoming undercross and the
 incoming overcross.

          EXAMPLES::

 @@ -705,16 +685,14 @@ class Link:

      def _braidwordcomponents_(self):
          """
 -        Return the disjoint braid components, if any, else returns the
 braid itself.
 -        For example consider the braid [-1, 3, 1, 3] this can be viewed
 as a braid
 +        Return the disjoint braid components, if any, else return the
 braid itself.
 +        For example consider the braid [-1, 3, 1, 3]. This can be viewed
 as a braid
          with components as [-1, 1] and [3, 3]. There is no common
 crossing to these
          two (in sense there is a crossing between strand 1 and 2,
 crossing between
          3 and 4 but no crossing between strand 2 and 3,so these can be
 viewed as
          independent components in the braid).

 -        OUTPUT:
 -
 -        - List containing the components is returned
 +        OUTPUT: List containing the components is returned

          EXAMPLES::

 @@ -733,7 +711,7 @@ class Link:
          b = self.braid()
          ml = list(b.Tietze())
          if ml == []:
 -            raise Exception("The braid remains the same with no
 components")
 +            raise ValueError("The braid remains the same with no
 components")
          else:
              l = list(set([abs(k) for k in ml]))
              missing1 = list(set(range(min(l), max(l) + 1)) - set(l))
 @@ -755,11 +733,9 @@ class Link:

      def _braidwordcomponentsvector_(self):
          """
 -        The list from the braidwordcomponents is flattened to give out
 the vector form.
 +        The list from :meth:`_braidwordcomponents_` is flattened to give
 the vector form.

 -        OUTPUT:
 -
 -        - Vector containing braidwordcomponents
 +        OUTPUT: Vector containing :meth:`_braidwordcomponents_`

          EXAMPLES::

 @@ -780,14 +756,13 @@ class Link:

      def _homology_generators_(self):
          """
 -        The set of generators for the first homology group of the
 connected Seifert surface of the given link.
 -        This method uses the braidwordcomponentsvector to generate the
 homology generators.
 -        The position of the repeated element w.r.t the
 braidwordcomponentvector list is
 -        compiled into a list.
 -
 -        OUTPUT:
 +        The set of generators for the first homology group of the
 +        connected Seifert surface of the given link.  This method uses
 +        :meth:`_braidwordcomponentsvector_` to generate the homology
 +        generators.  The position of the repeated element w.r.t.
 +        :meth:`_braidwordcomponentsvector_` is compiled into a list.

 -        - The homology generators relating to the braid word
 representation
 +        OUTPUT: The homology generators relating to the braid word
 representation

          EXAMPLES::

 @@ -802,6 +777,7 @@ class Link:
              sage: L = Link(B([-2, 4, 1, 6, 1, 4]))
              sage: L._homology_generators_()
              [0, 2, 0, 4, 0]
 +
          """
          x4 = self._braidwordcomponentsvector_()
          hom_gen = []
 @@ -819,10 +795,8 @@ class Link:
          """
          Return the Seifert Matrix associated with the link.

 -        OUTPUT:
 -
 -        - The intersection matrix of a (not necessarily minimal) Seifert
 surface of the
 -          link.
 +        OUTPUT: The intersection matrix of a (not necessarily minimal)
 Seifert
 +        surface of the link.

          EXAMPLES::

 @@ -892,9 +866,7 @@ class Link:
          """
          Return the number of connected components of the link.

 -        OUTPUT:
 -
 -        - Connected components of the link
 +        OUTPUT: Connected components of the link

          EXAMPLES::

 @@ -919,12 +891,10 @@ class Link:

      def is_knot(self):
          """
 -        Return True if the link is knot.
 +        Return True if the link is a knot.
          Every knot is a link but the converse is not true.

 -        OUTPUT:
 -
 -        - True if knot else False
 +        OUTPUT: True if knot else False

          EXAMPLES::

 @@ -946,9 +916,7 @@ class Link:
          """
          Return the genus of the link

 -        OUTPUT:
 -
 -        - Genus of the Link
 +        OUTPUT: genus of the link

          EXAMPLES::

 @@ -1004,9 +972,7 @@ class Link:
          """
          Return the signature of the link

 -        OUTPUT:
 -
 -        - Signature of the Link
 +        OUTPUT: signature of the link

          EXAMPLES::

 @@ -1039,9 +1005,7 @@ class Link:

          - ``var`` -- (default: ``'t'``); the variable in the polynomial.

 -        OUTPUT:
 -
 -        - Alexander Polynomial of the Link
 +        OUTPUT: Alexander Polynomial of the Link

          EXAMPLES::

 @@ -1067,9 +1031,7 @@ class Link:
          """
          Return the determinant of the knot

 -        OUTPUT:
 -
 -        - Determinant of the Knot
 +        OUTPUT: determinant of the knot

          EXAMPLES::

 @@ -1089,15 +1051,13 @@ class Link:
              a = self.alexander_polynomial()
              return Integer(abs(a(-1)))
          else:
 -            raise Exception("Determinant implmented only for knots")
 +            raise ValueError("Determinant implemented only for knots")

      def arf_invariant(self):
          """
          Return the arf invariant. Arf invariant is defined only for
 knots.

 -        OUTPUT:
 -
 -        - Arf invariant of knot
 +        OUTPUT: Arf invariant of the knot

          EXAMPLES::

 @@ -1120,20 +1080,16 @@ class Link:
              else:
                  return 1
          else:
 -            raise Exception("Arf invariant is defined only for knots")
 +            raise ValueError("Arf invariant is defined only for knots")

      def is_alternating(self):
          """
 -        Return True if the given knot diagram is alternating else returns
 False.
 -        Alternating diagram implies every over cross is followed by an
 under cross
 +        Return True if the given knot diagram is alternating else return
 False.
 +        Alternating diagram means that every over cross is followed by an
 under cross
          or the vice-versa.

 -        We look at the gauss code if the sign is alternating, True is
 returned else
 -        the knot is not alternating False is returned.
 -
 -        OUTPUT:
 -
 -        - True if the knot diagram is alternating else False
 +        In the gauss code, if the sign is alternating, True is returned,
 else
 +        the knot is not alternating so False is returned.

          EXAMPLES::

 @@ -1169,10 +1125,6 @@ class Link:
          """
          Return the orientation of the crossings of the link diagram.

 -        OUTPUT:
 -
 -        - Orientation  of the crossings.
 -
          EXAMPLES::

              sage: L = Link([[1, 4, 5, 2], [3, 5, 6, 7], [4, 8, 9, 6], [7,
 9, 10, 11], [8, 1, 13, 10], [11, 13, 2, 3]])
 @@ -1201,15 +1153,11 @@ class Link:

      def seifert_circles(self):
          """
 -        Return the seifert circles from the link diagram. Seifert circles
 are the circles
 +        Return the Seifert circles from the link diagram. Seifert circles
 are the circles
          obtained by smoothing all crossings respecting the orientation of
 the segments.

          Each Seifert circle is represented as a list of the segments that
 form it.

 -        OUTPUT:
 -
 -        - Seifert circles of the given link diagram.
 -
          EXAMPLES::

              sage: L = Link([[[1, -2, 3, -4, 2, -1, 4, -3]],[1, 1, -1,
 -1]])
 @@ -1263,9 +1211,7 @@ class Link:
          its boundary, with a sign deppending on the orientation of the
 segment
          as part of the boundary.

 -        OUTPUT:
 -
 -        - Regions of the knot.
 +        OUTPUT: regions of the knot

          EXAMPLES::

 @@ -1344,9 +1290,7 @@ class Link:
          """
          Return the writhe of the knot.

 -        OUTPUT:
 -
 -        - Writhe of the knot.
 +        OUTPUT: writhe of the knot

          EXAMPLES::

 @@ -1367,16 +1311,14 @@ class Link:

      def jones_polynomial(self, var='q'):
          """
 -        Return the jones polynomial of the link.
 +        Return the Jones polynomial of the link.

          INPUT:

          - ``var`` -- (default: ``'q'``); the variable in the polynomial.

 -        OUTPUT:
 -
 -        - Jones Polynomial of the link. It is a polynomial in var, as an
 element
 -          of the symbolic ring.
 +        OUTPUT: Jones polynomial of the link. It is a polynomial in
 +        ``var``, as an element of the symbolic ring.

          EXAMPLES::

 @@ -1394,6 +1336,7 @@ class Link:
              sage: L = Link(l5)
              sage: L.jones_polynomial()
              -q^(3/2) + sqrt(q) - 2/sqrt(q) + 1/q^(3/2) - 2/q^(5/2) +
 1/q^(7/2)
 +
          """
          t = SR(var)
          poly = self._bracket_(t)
 @@ -1420,8 +1363,6 @@ class Link:
              sage: L = Link([[2, 1, 3, 4], [4, 3, 1, 2]])
              sage: L._bracket_()
              -q^4 - 1/q^4
 -
 -
          """
          t = SR(variable)
          if len(self.PD_code()) == 1:
 @@ -1482,7 +1423,6 @@ class Link:
              sage: L = Link([[1, 1, 2, 2], [3, 3, 4, 4]])
              sage: L._isolated_components_()
              [[[1, 1, 2, 2]], [[3, 3, 4, 4]]]
 -
          """
          G = Graph()
          for c in self.PD_code():
 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/17030#comment:117>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to