passagemath-graphs 10.6.1rc1__cp310-cp310-musllinux_1_2_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. passagemath_graphs-10.6.1rc1.dist-info/METADATA +292 -0
  2. passagemath_graphs-10.6.1rc1.dist-info/RECORD +260 -0
  3. passagemath_graphs-10.6.1rc1.dist-info/WHEEL +5 -0
  4. passagemath_graphs-10.6.1rc1.dist-info/top_level.txt +2 -0
  5. passagemath_graphs.libs/libgcc_s-69c45f16.so.1 +0 -0
  6. passagemath_graphs.libs/libgmp-8e78bd9b.so.10.5.0 +0 -0
  7. passagemath_graphs.libs/libstdc++-1f1a71be.so.6.0.33 +0 -0
  8. sage/all__sagemath_graphs.py +39 -0
  9. sage/combinat/abstract_tree.py +2723 -0
  10. sage/combinat/all__sagemath_graphs.py +34 -0
  11. sage/combinat/binary_tree.py +5306 -0
  12. sage/combinat/cluster_algebra_quiver/all.py +22 -0
  13. sage/combinat/cluster_algebra_quiver/cluster_seed.py +5208 -0
  14. sage/combinat/cluster_algebra_quiver/interact.py +124 -0
  15. sage/combinat/cluster_algebra_quiver/mutation_class.py +625 -0
  16. sage/combinat/cluster_algebra_quiver/mutation_type.py +1555 -0
  17. sage/combinat/cluster_algebra_quiver/quiver.py +2290 -0
  18. sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py +2468 -0
  19. sage/combinat/designs/MOLS_handbook_data.py +570 -0
  20. sage/combinat/designs/all.py +58 -0
  21. sage/combinat/designs/bibd.py +1655 -0
  22. sage/combinat/designs/block_design.py +1071 -0
  23. sage/combinat/designs/covering_array.py +269 -0
  24. sage/combinat/designs/covering_design.py +530 -0
  25. sage/combinat/designs/database.py +5615 -0
  26. sage/combinat/designs/design_catalog.py +122 -0
  27. sage/combinat/designs/designs_pyx.cpython-310-aarch64-linux-gnu.so +0 -0
  28. sage/combinat/designs/designs_pyx.pxd +21 -0
  29. sage/combinat/designs/designs_pyx.pyx +993 -0
  30. sage/combinat/designs/difference_family.py +3951 -0
  31. sage/combinat/designs/difference_matrices.py +279 -0
  32. sage/combinat/designs/evenly_distributed_sets.cpython-310-aarch64-linux-gnu.so +0 -0
  33. sage/combinat/designs/evenly_distributed_sets.pyx +661 -0
  34. sage/combinat/designs/ext_rep.py +1064 -0
  35. sage/combinat/designs/gen_quadrangles_with_spread.cpython-310-aarch64-linux-gnu.so +0 -0
  36. sage/combinat/designs/gen_quadrangles_with_spread.pyx +339 -0
  37. sage/combinat/designs/group_divisible_designs.py +361 -0
  38. sage/combinat/designs/incidence_structures.py +2357 -0
  39. sage/combinat/designs/latin_squares.py +581 -0
  40. sage/combinat/designs/orthogonal_arrays.py +2244 -0
  41. sage/combinat/designs/orthogonal_arrays_build_recursive.py +1780 -0
  42. sage/combinat/designs/orthogonal_arrays_find_recursive.cpython-310-aarch64-linux-gnu.so +0 -0
  43. sage/combinat/designs/orthogonal_arrays_find_recursive.pyx +967 -0
  44. sage/combinat/designs/resolvable_bibd.py +815 -0
  45. sage/combinat/designs/steiner_quadruple_systems.py +1306 -0
  46. sage/combinat/designs/subhypergraph_search.cpython-310-aarch64-linux-gnu.so +0 -0
  47. sage/combinat/designs/subhypergraph_search.pyx +530 -0
  48. sage/combinat/designs/twographs.py +306 -0
  49. sage/combinat/finite_state_machine.py +14874 -0
  50. sage/combinat/finite_state_machine_generators.py +2006 -0
  51. sage/combinat/graph_path.py +448 -0
  52. sage/combinat/interval_posets.py +3908 -0
  53. sage/combinat/nu_tamari_lattice.py +269 -0
  54. sage/combinat/ordered_tree.py +1446 -0
  55. sage/combinat/posets/all.py +46 -0
  56. sage/combinat/posets/bubble_shuffle.py +247 -0
  57. sage/combinat/posets/cartesian_product.py +493 -0
  58. sage/combinat/posets/d_complete.py +182 -0
  59. sage/combinat/posets/elements.py +273 -0
  60. sage/combinat/posets/forest.py +30 -0
  61. sage/combinat/posets/hasse_cython.cpython-310-aarch64-linux-gnu.so +0 -0
  62. sage/combinat/posets/hasse_cython.pyx +174 -0
  63. sage/combinat/posets/hasse_diagram.py +3672 -0
  64. sage/combinat/posets/hochschild_lattice.py +158 -0
  65. sage/combinat/posets/incidence_algebras.py +794 -0
  66. sage/combinat/posets/lattices.py +5117 -0
  67. sage/combinat/posets/linear_extension_iterator.cpython-310-aarch64-linux-gnu.so +0 -0
  68. sage/combinat/posets/linear_extension_iterator.pyx +292 -0
  69. sage/combinat/posets/linear_extensions.py +1037 -0
  70. sage/combinat/posets/mobile.py +275 -0
  71. sage/combinat/posets/moebius_algebra.py +776 -0
  72. sage/combinat/posets/poset_examples.py +2178 -0
  73. sage/combinat/posets/posets.py +9360 -0
  74. sage/combinat/rooted_tree.py +1070 -0
  75. sage/combinat/shard_order.py +239 -0
  76. sage/combinat/tamari_lattices.py +384 -0
  77. sage/combinat/yang_baxter_graph.py +923 -0
  78. sage/databases/all__sagemath_graphs.py +1 -0
  79. sage/databases/knotinfo_db.py +1231 -0
  80. sage/ext_data/all__sagemath_graphs.py +1 -0
  81. sage/ext_data/graphs/graph_plot_js.html +330 -0
  82. sage/ext_data/kenzo/CP2.txt +45 -0
  83. sage/ext_data/kenzo/CP3.txt +349 -0
  84. sage/ext_data/kenzo/CP4.txt +4774 -0
  85. sage/ext_data/kenzo/README.txt +49 -0
  86. sage/ext_data/kenzo/S4.txt +20 -0
  87. sage/graphs/all.py +42 -0
  88. sage/graphs/asteroidal_triples.cpython-310-aarch64-linux-gnu.so +0 -0
  89. sage/graphs/asteroidal_triples.pyx +320 -0
  90. sage/graphs/base/all.py +1 -0
  91. sage/graphs/base/boost_graph.cpython-310-aarch64-linux-gnu.so +0 -0
  92. sage/graphs/base/boost_graph.pxd +106 -0
  93. sage/graphs/base/boost_graph.pyx +3045 -0
  94. sage/graphs/base/c_graph.cpython-310-aarch64-linux-gnu.so +0 -0
  95. sage/graphs/base/c_graph.pxd +106 -0
  96. sage/graphs/base/c_graph.pyx +5096 -0
  97. sage/graphs/base/dense_graph.cpython-310-aarch64-linux-gnu.so +0 -0
  98. sage/graphs/base/dense_graph.pxd +28 -0
  99. sage/graphs/base/dense_graph.pyx +801 -0
  100. sage/graphs/base/graph_backends.cpython-310-aarch64-linux-gnu.so +0 -0
  101. sage/graphs/base/graph_backends.pxd +5 -0
  102. sage/graphs/base/graph_backends.pyx +797 -0
  103. sage/graphs/base/overview.py +85 -0
  104. sage/graphs/base/sparse_graph.cpython-310-aarch64-linux-gnu.so +0 -0
  105. sage/graphs/base/sparse_graph.pxd +90 -0
  106. sage/graphs/base/sparse_graph.pyx +1653 -0
  107. sage/graphs/base/static_dense_graph.cpython-310-aarch64-linux-gnu.so +0 -0
  108. sage/graphs/base/static_dense_graph.pxd +5 -0
  109. sage/graphs/base/static_dense_graph.pyx +1032 -0
  110. sage/graphs/base/static_sparse_backend.cpython-310-aarch64-linux-gnu.so +0 -0
  111. sage/graphs/base/static_sparse_backend.pxd +27 -0
  112. sage/graphs/base/static_sparse_backend.pyx +1583 -0
  113. sage/graphs/base/static_sparse_graph.cpython-310-aarch64-linux-gnu.so +0 -0
  114. sage/graphs/base/static_sparse_graph.pxd +37 -0
  115. sage/graphs/base/static_sparse_graph.pyx +1375 -0
  116. sage/graphs/bipartite_graph.py +2732 -0
  117. sage/graphs/centrality.cpython-310-aarch64-linux-gnu.so +0 -0
  118. sage/graphs/centrality.pyx +1038 -0
  119. sage/graphs/cographs.py +519 -0
  120. sage/graphs/comparability.cpython-310-aarch64-linux-gnu.so +0 -0
  121. sage/graphs/comparability.pyx +851 -0
  122. sage/graphs/connectivity.cpython-310-aarch64-linux-gnu.so +0 -0
  123. sage/graphs/connectivity.pxd +157 -0
  124. sage/graphs/connectivity.pyx +4813 -0
  125. sage/graphs/convexity_properties.cpython-310-aarch64-linux-gnu.so +0 -0
  126. sage/graphs/convexity_properties.pxd +16 -0
  127. sage/graphs/convexity_properties.pyx +870 -0
  128. sage/graphs/digraph.py +4754 -0
  129. sage/graphs/digraph_generators.py +1993 -0
  130. sage/graphs/distances_all_pairs.cpython-310-aarch64-linux-gnu.so +0 -0
  131. sage/graphs/distances_all_pairs.pxd +12 -0
  132. sage/graphs/distances_all_pairs.pyx +2938 -0
  133. sage/graphs/domination.py +1363 -0
  134. sage/graphs/dot2tex_utils.py +100 -0
  135. sage/graphs/edge_connectivity.cpython-310-aarch64-linux-gnu.so +0 -0
  136. sage/graphs/edge_connectivity.pyx +1215 -0
  137. sage/graphs/generators/all.py +1 -0
  138. sage/graphs/generators/basic.py +1769 -0
  139. sage/graphs/generators/chessboard.py +538 -0
  140. sage/graphs/generators/classical_geometries.py +1611 -0
  141. sage/graphs/generators/degree_sequence.py +235 -0
  142. sage/graphs/generators/distance_regular.cpython-310-aarch64-linux-gnu.so +0 -0
  143. sage/graphs/generators/distance_regular.pyx +2846 -0
  144. sage/graphs/generators/families.py +4759 -0
  145. sage/graphs/generators/intersection.py +565 -0
  146. sage/graphs/generators/platonic_solids.py +262 -0
  147. sage/graphs/generators/random.py +2623 -0
  148. sage/graphs/generators/smallgraphs.py +5741 -0
  149. sage/graphs/generators/world_map.py +724 -0
  150. sage/graphs/generic_graph.py +26867 -0
  151. sage/graphs/generic_graph_pyx.cpython-310-aarch64-linux-gnu.so +0 -0
  152. sage/graphs/generic_graph_pyx.pxd +34 -0
  153. sage/graphs/generic_graph_pyx.pyx +1673 -0
  154. sage/graphs/genus.cpython-310-aarch64-linux-gnu.so +0 -0
  155. sage/graphs/genus.pyx +622 -0
  156. sage/graphs/graph.py +9645 -0
  157. sage/graphs/graph_coloring.cpython-310-aarch64-linux-gnu.so +0 -0
  158. sage/graphs/graph_coloring.pyx +2284 -0
  159. sage/graphs/graph_database.py +1177 -0
  160. sage/graphs/graph_decompositions/all.py +1 -0
  161. sage/graphs/graph_decompositions/bandwidth.cpython-310-aarch64-linux-gnu.so +0 -0
  162. sage/graphs/graph_decompositions/bandwidth.pyx +428 -0
  163. sage/graphs/graph_decompositions/clique_separators.cpython-310-aarch64-linux-gnu.so +0 -0
  164. sage/graphs/graph_decompositions/clique_separators.pyx +616 -0
  165. sage/graphs/graph_decompositions/cutwidth.cpython-310-aarch64-linux-gnu.so +0 -0
  166. sage/graphs/graph_decompositions/cutwidth.pyx +753 -0
  167. sage/graphs/graph_decompositions/fast_digraph.cpython-310-aarch64-linux-gnu.so +0 -0
  168. sage/graphs/graph_decompositions/fast_digraph.pxd +13 -0
  169. sage/graphs/graph_decompositions/fast_digraph.pyx +212 -0
  170. sage/graphs/graph_decompositions/graph_products.cpython-310-aarch64-linux-gnu.so +0 -0
  171. sage/graphs/graph_decompositions/graph_products.pyx +508 -0
  172. sage/graphs/graph_decompositions/modular_decomposition.cpython-310-aarch64-linux-gnu.so +0 -0
  173. sage/graphs/graph_decompositions/modular_decomposition.pxd +27 -0
  174. sage/graphs/graph_decompositions/modular_decomposition.pyx +1536 -0
  175. sage/graphs/graph_decompositions/slice_decomposition.cpython-310-aarch64-linux-gnu.so +0 -0
  176. sage/graphs/graph_decompositions/slice_decomposition.pxd +18 -0
  177. sage/graphs/graph_decompositions/slice_decomposition.pyx +1106 -0
  178. sage/graphs/graph_decompositions/tree_decomposition.cpython-310-aarch64-linux-gnu.so +0 -0
  179. sage/graphs/graph_decompositions/tree_decomposition.pxd +17 -0
  180. sage/graphs/graph_decompositions/tree_decomposition.pyx +1996 -0
  181. sage/graphs/graph_decompositions/vertex_separation.cpython-310-aarch64-linux-gnu.so +0 -0
  182. sage/graphs/graph_decompositions/vertex_separation.pxd +5 -0
  183. sage/graphs/graph_decompositions/vertex_separation.pyx +1963 -0
  184. sage/graphs/graph_editor.py +82 -0
  185. sage/graphs/graph_generators.py +3314 -0
  186. sage/graphs/graph_generators_pyx.cpython-310-aarch64-linux-gnu.so +0 -0
  187. sage/graphs/graph_generators_pyx.pyx +95 -0
  188. sage/graphs/graph_input.py +812 -0
  189. sage/graphs/graph_latex.py +2064 -0
  190. sage/graphs/graph_list.py +410 -0
  191. sage/graphs/graph_plot.py +1756 -0
  192. sage/graphs/graph_plot_js.py +338 -0
  193. sage/graphs/hyperbolicity.cpython-310-aarch64-linux-gnu.so +0 -0
  194. sage/graphs/hyperbolicity.pyx +1704 -0
  195. sage/graphs/hypergraph_generators.py +364 -0
  196. sage/graphs/independent_sets.cpython-310-aarch64-linux-gnu.so +0 -0
  197. sage/graphs/independent_sets.pxd +13 -0
  198. sage/graphs/independent_sets.pyx +402 -0
  199. sage/graphs/isgci.py +1033 -0
  200. sage/graphs/isoperimetric_inequalities.cpython-310-aarch64-linux-gnu.so +0 -0
  201. sage/graphs/isoperimetric_inequalities.pyx +489 -0
  202. sage/graphs/line_graph.cpython-310-aarch64-linux-gnu.so +0 -0
  203. sage/graphs/line_graph.pyx +743 -0
  204. sage/graphs/lovasz_theta.py +77 -0
  205. sage/graphs/matching.py +1633 -0
  206. sage/graphs/matching_covered_graph.py +3590 -0
  207. sage/graphs/orientations.py +1489 -0
  208. sage/graphs/partial_cube.py +459 -0
  209. sage/graphs/path_enumeration.cpython-310-aarch64-linux-gnu.so +0 -0
  210. sage/graphs/path_enumeration.pyx +2040 -0
  211. sage/graphs/pq_trees.py +1129 -0
  212. sage/graphs/print_graphs.py +201 -0
  213. sage/graphs/schnyder.py +865 -0
  214. sage/graphs/spanning_tree.cpython-310-aarch64-linux-gnu.so +0 -0
  215. sage/graphs/spanning_tree.pyx +1457 -0
  216. sage/graphs/strongly_regular_db.cpython-310-aarch64-linux-gnu.so +0 -0
  217. sage/graphs/strongly_regular_db.pyx +3340 -0
  218. sage/graphs/traversals.cpython-310-aarch64-linux-gnu.so +0 -0
  219. sage/graphs/traversals.pxd +9 -0
  220. sage/graphs/traversals.pyx +1872 -0
  221. sage/graphs/trees.cpython-310-aarch64-linux-gnu.so +0 -0
  222. sage/graphs/trees.pxd +15 -0
  223. sage/graphs/trees.pyx +310 -0
  224. sage/graphs/tutte_polynomial.py +713 -0
  225. sage/graphs/views.cpython-310-aarch64-linux-gnu.so +0 -0
  226. sage/graphs/views.pyx +794 -0
  227. sage/graphs/weakly_chordal.cpython-310-aarch64-linux-gnu.so +0 -0
  228. sage/graphs/weakly_chordal.pyx +604 -0
  229. sage/groups/all__sagemath_graphs.py +1 -0
  230. sage/groups/perm_gps/all__sagemath_graphs.py +1 -0
  231. sage/groups/perm_gps/partn_ref/all__sagemath_graphs.py +1 -0
  232. sage/groups/perm_gps/partn_ref/refinement_graphs.cpython-310-aarch64-linux-gnu.so +0 -0
  233. sage/groups/perm_gps/partn_ref/refinement_graphs.pxd +38 -0
  234. sage/groups/perm_gps/partn_ref/refinement_graphs.pyx +1666 -0
  235. sage/knots/all.py +6 -0
  236. sage/knots/free_knotinfo_monoid.py +507 -0
  237. sage/knots/gauss_code.py +291 -0
  238. sage/knots/knot.py +682 -0
  239. sage/knots/knot_table.py +284 -0
  240. sage/knots/knotinfo.py +2900 -0
  241. sage/knots/link.py +4715 -0
  242. sage/sandpiles/all.py +13 -0
  243. sage/sandpiles/examples.py +225 -0
  244. sage/sandpiles/sandpile.py +6365 -0
  245. sage/topology/all.py +22 -0
  246. sage/topology/cell_complex.py +1214 -0
  247. sage/topology/cubical_complex.py +1976 -0
  248. sage/topology/delta_complex.py +1806 -0
  249. sage/topology/filtered_simplicial_complex.py +744 -0
  250. sage/topology/moment_angle_complex.py +823 -0
  251. sage/topology/simplicial_complex.py +5160 -0
  252. sage/topology/simplicial_complex_catalog.py +92 -0
  253. sage/topology/simplicial_complex_examples.py +1680 -0
  254. sage/topology/simplicial_complex_homset.py +205 -0
  255. sage/topology/simplicial_complex_morphism.py +836 -0
  256. sage/topology/simplicial_set.py +4102 -0
  257. sage/topology/simplicial_set_catalog.py +55 -0
  258. sage/topology/simplicial_set_constructions.py +2954 -0
  259. sage/topology/simplicial_set_examples.py +865 -0
  260. sage/topology/simplicial_set_morphism.py +1464 -0
sage/knots/knot.py ADDED
@@ -0,0 +1,682 @@
1
+ # sage_setup: distribution = sagemath-graphs
2
+ # sage.doctest: needs sage.graphs sage.groups
3
+ r"""
4
+ Knots
5
+
6
+ AUTHORS:
7
+
8
+ - Miguel Angel Marco Buzunariz
9
+ - Amit Jamadagni
10
+ """
11
+
12
+ # ****************************************************************************
13
+ # Copyright (C) 2014 Travis Scrimshaw <tscrim at ucdavis.edu>
14
+ #
15
+ # This program is free software: you can redistribute it and/or modify
16
+ # it under the terms of the GNU General Public License as published by
17
+ # the Free Software Foundation, either version 2 of the License, or
18
+ # (at your option) any later version.
19
+ # https://www.gnu.org/licenses/
20
+ # ****************************************************************************
21
+
22
+ from sage.knots.link import Link
23
+ from sage.knots.knot_table import small_knots_table
24
+ from sage.knots.gauss_code import (recover_orientations, dowker_to_gauss,
25
+ rectangular_diagram)
26
+
27
+ from sage.structure.parent import Parent
28
+ from sage.structure.element import Element
29
+ from sage.misc.fast_methods import Singleton
30
+ from sage.misc.inherit_comparison import InheritComparisonClasscallMetaclass
31
+ from sage.categories.monoids import Monoids
32
+
33
+ # We need Link to be first in the MRO in order to use its equality, hash, etc.
34
+
35
+
36
+ class Knot(Link, Element, metaclass=InheritComparisonClasscallMetaclass):
37
+ r"""
38
+ A knot.
39
+
40
+ A knot is defined as embedding of the circle `\mathbb{S}^1` in the
41
+ 3-dimensional sphere `\mathbb{S}^3`, considered up to ambient isotopy.
42
+ They represent the physical idea of a knotted rope, but with the
43
+ particularity that the rope is closed. That is, the ends of the rope
44
+ are joined.
45
+
46
+ .. SEEALSO::
47
+
48
+ :class:`Link`
49
+
50
+ INPUT:
51
+
52
+ - ``data`` -- see :class:`Link` for the allowable inputs
53
+ - ``check`` -- boolean (default: ``True``); if ``True``, make sure
54
+ that the data define a knot, not a link
55
+
56
+ EXAMPLES:
57
+
58
+ We construct the knot `8_{14}` and compute some invariants::
59
+
60
+ sage: B = BraidGroup(4)
61
+ sage: K = Knot(B([1,1,1,2,-1,2,-3,2,-3]))
62
+
63
+ .. PLOT::
64
+ :width: 300 px
65
+
66
+ B = BraidGroup(4)
67
+ K = Knot(B([1,1,1,2,-1,2,-3,2,-3]))
68
+ sphinx_plot(K.plot())
69
+
70
+ ::
71
+
72
+ sage: K.alexander_polynomial()
73
+ -2*t^-2 + 8*t^-1 - 11 + 8*t - 2*t^2
74
+ sage: K.jones_polynomial() # needs sage.symbolic
75
+ t^7 - 3*t^6 + 4*t^5 - 5*t^4 + 6*t^3 - 5*t^2 + 4*t + 1/t - 2
76
+ sage: K.determinant()
77
+ 31
78
+ sage: K.signature()
79
+ -2
80
+ sage: K.colored_jones_polynomial(2) # long time
81
+ q^-1 - 2 + 4*q - 5*q^2 + 6*q^3 - 5*q^4 + 4*q^5 - 3*q^6 + q^7
82
+
83
+ REFERENCES:
84
+
85
+ - :wikipedia:`Knot_(mathematics)`
86
+ """
87
+ @staticmethod
88
+ def __classcall_private__(self, data, check=True):
89
+ """
90
+ Make sure this is an instance of the element class
91
+ of :class:`Knots`.
92
+
93
+ EXAMPLES::
94
+
95
+ sage: B = BraidGroup(8)
96
+ sage: K = Knot(B([-1, -1, -1, 2, 1, -2, 3, -2, 3]))
97
+ sage: type(K)
98
+ <class 'sage.knots.knot.Knots_with_category.element_class'>
99
+ """
100
+ return Knots().element_class(data, check=check)
101
+
102
+ def __init__(self, data, check=True):
103
+ """
104
+ Initialize ``self``.
105
+
106
+ TESTS::
107
+
108
+ sage: B = BraidGroup(8)
109
+ sage: K = Knot(B([1, -2, 1, -2]))
110
+ sage: TestSuite(K).run()
111
+ sage: K = Knot([[1, 1, 2, 2]])
112
+ sage: TestSuite(K).run()
113
+
114
+ The following is not a knot: it has two components. ::
115
+
116
+ sage: Knot([[[1, 2], [-2, -1]], [1, -1]])
117
+ Traceback (most recent call last):
118
+ ...
119
+ ValueError: the input has more than 1 connected component
120
+
121
+ sage: Knot([[[1, 2], [-2, -1]], [1, -1]], check=False)
122
+ Knot represented by 2 crossings
123
+ """
124
+ Element.__init__(self, Knots())
125
+ Link.__init__(self, data)
126
+ if check:
127
+ if self.number_of_components() != 1:
128
+ raise ValueError("the input has more than 1 connected "
129
+ "component")
130
+
131
+ def _repr_(self):
132
+ """
133
+ Return a string representation.
134
+
135
+ EXAMPLES::
136
+
137
+ sage: B = BraidGroup(8)
138
+ sage: K = Knot(B([1, 2, 1, 2]))
139
+ sage: K
140
+ Knot represented by 4 crossings
141
+ sage: K = Knot([[1, 7, 2, 6], [7, 3, 8, 2], [3, 11, 4, 10],
142
+ ....: [11, 5, 12, 4], [14, 5, 1, 6], [13, 9, 14, 8],
143
+ ....: [12, 9, 13, 10]])
144
+ sage: K
145
+ Knot represented by 7 crossings
146
+ """
147
+ pd_len = len(self.pd_code())
148
+ return 'Knot represented by {} crossings'.format(pd_len)
149
+
150
+ def _unicode_art_(self):
151
+ """
152
+ Return unicode art for the knot.
153
+
154
+ EXAMPLES::
155
+
156
+ sage: W = Knots()
157
+ sage: K = W.from_dowker_code([-4,-6,-2])
158
+ sage: unicode_art(K)
159
+ ╭─╮
160
+ ╭──│╮
161
+ │╰╮││
162
+ │ ╰─╯
163
+ ╰──╯
164
+
165
+ sage: G = [-1, 2, -3, 4, 6, -7, 8, 1, -2, 3, -4, -5, 7, -8, 5, -6]
166
+ sage: K = Knots().from_gauss_code(G)
167
+ sage: unicode_art(K)
168
+ ╭─────╮
169
+ │╭─────╮
170
+ ╭─│╮ ││
171
+ ╭─╯││ ││
172
+ │╰─╯│ ││
173
+ │ ╰──╮││
174
+ │ ╭│╯│
175
+ │ ╭│╯ │
176
+ ╭─────│╯ │
177
+ │╰────╯ │
178
+ ╰─────────╯
179
+
180
+ TESTS::
181
+
182
+ sage: W = Knots()
183
+ sage: unicode_art(W.one())
184
+ ╭╮
185
+ ╰╯
186
+ """
187
+ style = 2 # among 0, 1, 2 (how to display crossings, see below)
188
+ gauss = self.gauss_code()
189
+ if not gauss:
190
+ gauss = []
191
+ else:
192
+ gauss = gauss[0]
193
+
194
+ graphe, (hori, vert) = rectangular_diagram(gauss)
195
+ maxx, maxy = 0, 0
196
+ for a, b in graphe:
197
+ maxx = max(a, maxx)
198
+ maxy = max(b, maxy)
199
+ M = [[" " for a in range(maxy + 1)] for b in range(maxx + 1)]
200
+ for a, b in graphe:
201
+ (x, y), (xx, yy) = graphe.neighbors((a, b))
202
+ if x != a:
203
+ x, y, xx, yy = xx, yy, x, y
204
+ if y < b:
205
+ if xx < a:
206
+ M[a][b] = "╯"
207
+ else:
208
+ M[a][b] = "╮"
209
+ else:
210
+ if xx < a:
211
+ M[a][b] = "╰"
212
+ else:
213
+ M[a][b] = "╭"
214
+
215
+ for ab, cd in graphe.edge_iterator(labels=False):
216
+ a, b = ab
217
+ c, d = cd
218
+ if a == c:
219
+ b, d = sorted((b, d))
220
+ for i in range(b + 1, d):
221
+ M[a][i] = "─"
222
+ else:
223
+ a, c = sorted((a, c))
224
+ for i in range(a + 1, c):
225
+ M[i][b] = "│"
226
+
227
+ if style == 0:
228
+ H = "┿"
229
+ V = "╂"
230
+ elif style == 1:
231
+ H = "━"
232
+ V = "┃"
233
+ elif style == 2:
234
+ H = "─"
235
+ V = "│"
236
+
237
+ for x, y in hori:
238
+ M[x][y] = H
239
+ for x, y in vert:
240
+ M[x][y] = V
241
+
242
+ from sage.typeset.unicode_art import UnicodeArt
243
+ return UnicodeArt([''.join(ligne) for ligne in M])
244
+
245
+ def dt_code(self):
246
+ """
247
+ Return the DT code of ``self``.
248
+
249
+ ALGORITHM:
250
+
251
+ The DT code is generated by the following way:
252
+
253
+ Start moving along the knot, as we encounter the crossings we
254
+ start numbering them, so every crossing has two numbers assigned to
255
+ it once we have traced the entire knot. Now we take the even number
256
+ associated with every crossing.
257
+
258
+ The following sign convention is to be followed:
259
+
260
+ Take the even number with a negative sign if it is an overcrossing
261
+ that we are encountering.
262
+
263
+ OUTPUT: DT code representation of the knot
264
+
265
+ EXAMPLES::
266
+
267
+ sage: K = Knot([[1,5,2,4],[5,3,6,2],[3,1,4,6]])
268
+ sage: K.dt_code()
269
+ [4, 6, 2]
270
+
271
+ sage: B = BraidGroup(4)
272
+ sage: K = Knot(B([1, 2, 1, 2]))
273
+ sage: K.dt_code()
274
+ [4, -6, 8, -2]
275
+
276
+ sage: K = Knot([[[1, -2, 3, -4, 5, -1, 2, -3, 4, -5]],
277
+ ....: [1, 1, 1, 1, 1]])
278
+ sage: K.dt_code()
279
+ [6, 8, 10, 2, 4]
280
+ """
281
+ b = self.braid().Tietze()
282
+ N = len(b)
283
+ label = [0 for i in range(2 * N)]
284
+ string = 1
285
+ next_label = 1
286
+ type1 = 0
287
+ crossing = 0
288
+ while next_label <= 2 * N:
289
+ string_found = False
290
+ for i in range(crossing, N):
291
+ if abs(b[i]) == string or abs(b[i]) == string - 1:
292
+ string_found = True
293
+ crossing = i
294
+ break
295
+ if not string_found:
296
+ for i in range(crossing):
297
+ if abs(b[i]) == string or abs(b[i]) == string - 1:
298
+ string_found = True
299
+ crossing = i
300
+ break
301
+ assert label[2 * crossing + next_label % 2] != 1, "invalid knot"
302
+
303
+ label[2 * crossing + next_label % 2] = next_label
304
+ next_label += 1
305
+ if type1 == 0:
306
+ if b[crossing] < 0:
307
+ type1 = 1
308
+ else:
309
+ type1 = -1
310
+ else:
311
+ type1 = -type1
312
+ if (abs(b[crossing]) == string) ^ (b[crossing] * type1 < 0):
313
+ if next_label % 2:
314
+ label[2 * crossing] = label[2 * crossing] * -1
315
+ if abs(b[crossing]) == string:
316
+ string += 1
317
+ else:
318
+ string -= 1
319
+ crossing += 1
320
+ code = [0 for _ in range(N)]
321
+ for i in range(N):
322
+ for j in range(N):
323
+ if label[2 * j + 1] == 2 * i + 1:
324
+ code[i] = label[2 * j]
325
+ break
326
+ return code
327
+
328
+ def arf_invariant(self):
329
+ """
330
+ Return the Arf invariant.
331
+
332
+ EXAMPLES::
333
+
334
+ sage: B = BraidGroup(4)
335
+ sage: K = Knot(B([-1, 2, 1, 2]))
336
+ sage: K.arf_invariant()
337
+ 0
338
+ sage: B = BraidGroup(8)
339
+ sage: K = Knot(B([-2, 3, 1, 2, 1, 4]))
340
+ sage: K.arf_invariant()
341
+ 0
342
+ sage: K = Knot(B([1, 2, 1, 2]))
343
+ sage: K.arf_invariant()
344
+ 1
345
+ """
346
+ a = self.alexander_polynomial()(-1)
347
+ if (a % 8) == 1 or (a % 8) == 7:
348
+ return 0
349
+ return 1
350
+
351
+ def colored_jones_polynomial(self, N, variab=None, try_inverse=True):
352
+ r"""
353
+ Return the colored Jones polynomial of the trace closure of the braid.
354
+
355
+ INPUT:
356
+
357
+ - ``N`` -- integer; the number of colors
358
+ - ``variab`` -- (default: `q`) the variable in the resulting
359
+ Laurent polynomial
360
+ - ``try_inverse`` -- boolean (default: ``True``); if ``True``,
361
+ attempt a faster calculation by using the inverse of the braid
362
+
363
+ ALGORITHM:
364
+
365
+ The algorithm used is described in [HL2018]_ for the corresponding
366
+ braid representation. We follow their notation, but work in a
367
+ suitable free algebra over a Laurent polynomial ring in one
368
+ variable to simplify bookkeeping.
369
+
370
+ EXAMPLES::
371
+
372
+ sage: W = Knots()
373
+ sage: K = W.from_dowker_code([-4,-6,-2])
374
+ sage: K.colored_jones_polynomial(2)
375
+ -q^-4 + q^-3 + q^-1
376
+ sage: K.colored_jones_polynomial(2, 't')
377
+ -t^-4 + t^-3 + t^-1
378
+ sage: R.<t> = LaurentPolynomialRing(ZZ)
379
+ sage: K.colored_jones_polynomial(2, -t)
380
+ -t^-4 - t^-3 - t^-1
381
+
382
+ sage: R.<t> = ZZ[]
383
+ sage: K.colored_jones_polynomial(2, t+1)
384
+ (t^3 + 3*t^2 + 4*t + 1)/(t^4 + 4*t^3 + 6*t^2 + 4*t + 1)
385
+ """
386
+ return self.braid().colored_jones_polynomial(N=N, variab=variab,
387
+ try_inverse=try_inverse)
388
+
389
+ def connected_sum(self, other):
390
+ r"""
391
+ Return the oriented connected sum of ``self`` and ``other``.
392
+
393
+ .. NOTE::
394
+
395
+ We give the knots an orientation based upon the braid
396
+ representation.
397
+
398
+ INPUT:
399
+
400
+ - ``other`` -- a knot
401
+
402
+ OUTPUT: a knot equivalent to the connected sum of ``self`` and ``other``
403
+
404
+ EXAMPLES::
405
+
406
+ sage: B = BraidGroup(2)
407
+ sage: trefoil = Knot(B([1,1,1]))
408
+ sage: K = trefoil.connected_sum(trefoil); K
409
+ Knot represented by 6 crossings
410
+ sage: K.braid()
411
+ s0^3*s1^-1*s0^3*s1
412
+
413
+ .. PLOT::
414
+ :width: 300 px
415
+
416
+ B = BraidGroup(2)
417
+ trefoil = Knot(B([1,1,1]))
418
+ K = trefoil.connected_sum(trefoil)
419
+ sphinx_plot(K.plot())
420
+
421
+ ::
422
+
423
+ sage: rev_trefoil = Knot(B([-1,-1,-1]))
424
+ sage: K2 = trefoil.connected_sum(rev_trefoil); K2
425
+ Knot represented by 6 crossings
426
+ sage: K2.braid()
427
+ s0^3*s1^-1*s0^-3*s1
428
+
429
+ .. PLOT::
430
+ :width: 300 px
431
+
432
+ B = BraidGroup(2)
433
+ t = Knot(B([1,1,1]))
434
+ tr = Knot(B([-1,-1,-1]))
435
+ K2 = t.connected_sum(tr)
436
+ sphinx_plot(K2.plot())
437
+
438
+ Observe that both knots have according ``dowker_notation`` (showing that
439
+ the constructing from DT-code may not be unique for non prime knots, see
440
+ :meth:`from_dowker_code`)::
441
+
442
+ sage: K.dowker_notation()
443
+ [(4, 1), (2, 5), (6, 3), (10, 7), (8, 11), (12, 9)]
444
+ sage: K2.dowker_notation()
445
+ [(4, 1), (2, 5), (6, 3), (7, 10), (11, 8), (9, 12)]
446
+ sage: K.homfly_polynomial() == K2.homfly_polynomial() # needs libhomfly
447
+ False
448
+
449
+ TESTS::
450
+
451
+ sage: B = BraidGroup(2)
452
+ sage: trivial = Knots().one()
453
+ sage: trivial * trivial
454
+ Knot represented by 0 crossings
455
+ sage: trefoil = Knot(B([1,1,1]))
456
+ sage: trefoil * trivial
457
+ Knot represented by 3 crossings
458
+ sage: trefoil * trefoil
459
+ Knot represented by 6 crossings
460
+
461
+ REFERENCES:
462
+
463
+ - :wikipedia:`Connected_sum`
464
+ """
465
+ from sage.functions.generalized import sign
466
+ ogc1 = self.oriented_gauss_code()
467
+ ogc2 = other.oriented_gauss_code()
468
+ if not ogc1[0]:
469
+ return other
470
+ if not ogc2[0]:
471
+ return self
472
+ # how much we have to "displace" the numbering of the
473
+ # crossings of other
474
+ m1 = max(abs(i) for i in ogc1[0][0])
475
+ m2 = min(abs(i) for i in ogc2[0][0])
476
+ n = m1 - m2 + 1
477
+ # construct the oriented Gauss code of the result
478
+ ogc2_0_0 = [a + int(sign(a)) * n for a in ogc2[0][0]]
479
+ nogc = [[ogc1[0][0] + ogc2_0_0], ogc1[1] + ogc2[1]]
480
+ return type(self)(nogc)
481
+
482
+ _mul_ = connected_sum
483
+
484
+
485
+ class Knots(Singleton, Parent):
486
+ """
487
+ The set for all knots, as a monoid for the connected sum.
488
+ """
489
+ def __init__(self):
490
+ """
491
+ TESTS::
492
+
493
+ sage: S = Knots()
494
+ sage: S.cardinality()
495
+ +Infinity
496
+ sage: TestSuite(S).run()
497
+ """
498
+ Parent.__init__(self, category=Monoids().Infinite())
499
+
500
+ def _repr_(self):
501
+ r"""
502
+ TESTS::
503
+
504
+ sage: Knots()
505
+ Knots
506
+ """
507
+ return "Knots"
508
+
509
+ def one(self):
510
+ """
511
+ Return the unit of the monoid.
512
+
513
+ This is the trivial knot.
514
+
515
+ EXAMPLES::
516
+
517
+ sage: Knots().one()
518
+ Knot represented by 0 crossings
519
+ """
520
+ return self.element_class([])
521
+
522
+ def an_element(self):
523
+ """
524
+ Return the trefoil knot.
525
+
526
+ EXAMPLES::
527
+
528
+ sage: Knots().an_element()
529
+ Knot represented by 3 crossings
530
+ """
531
+ return self.element_class([[1, 5, 2, 4], [5, 3, 6, 2], [3, 1, 4, 6]])
532
+
533
+ def from_gauss_code(self, gauss):
534
+ """
535
+ Build a knot from a signed Gauss code.
536
+
537
+ This makes some arbitrary choice of orientation.
538
+
539
+ INPUT:
540
+
541
+ - ``gauss`` -- a signed Gauss code
542
+
543
+ OUTPUT: a knot
544
+
545
+ EXAMPLES::
546
+
547
+ sage: W = Knots()
548
+ sage: K1 = W.from_gauss_code([2, -1, 3, -2, 1, -3])
549
+ sage: K1.alexander_polynomial()
550
+ t^-1 - 1 + t
551
+ """
552
+ orientations = recover_orientations(gauss)[3]
553
+ return Knot([[gauss], orientations])
554
+
555
+ def from_dowker_code(self, code):
556
+ """
557
+ Build a knot from a Dowker-Thistlethwaite code.
558
+
559
+ The Dowker-Thistlethwaite code of a knot diagram is defined as follows.
560
+
561
+ Start following the knot diagram at some regular point. Label the
562
+ crossings by a number (starting from number 1) in the order in
563
+ which they are met. At the end, every crossing gets numbered
564
+ twice, once by an even number and once by an odd number. When
565
+ meeting an over-crossing with even number, use instead the
566
+ negative of this even number as label.
567
+
568
+ Then the set of crossings gives a set of pairs (odd,
569
+ even). Sort this set according to the odd component, and then
570
+ keep only the even components in the same order. This is the
571
+ Dowker-Thistlethwaite code.
572
+
573
+ INPUT:
574
+
575
+ - ``code`` -- list of signed even numbers; the Dowker-Thistlethwaite
576
+ code of a knot
577
+
578
+ OUTPUT: a knot
579
+
580
+ .. WARNING::
581
+
582
+ In general the Dowker-Thistlethwaite code does not describe a knot
583
+ uniquely. It is not only insensitive on mirror images, but may also
584
+ mix up non prime knots. For example ``[4, 6, 2, 10, 12, 8]`` describes
585
+ the connected sum of two trefoil knots, as well as the connected sum
586
+ of a trefoil with its mirror (see the corresponding example in the
587
+ documentation of :meth:`connected_sum`).
588
+
589
+ EXAMPLES::
590
+
591
+ sage: W = Knots()
592
+ sage: K1 = W.from_dowker_code([8,10,2,12,4,6])
593
+ sage: K1.dowker_notation()
594
+ [(5, 2), (9, 4), (11, 6), (1, 8), (3, 10), (7, 12)]
595
+
596
+ sage: W.from_dowker_code([6,10,14,12,16,2,18,4,8])
597
+ Knot represented by 9 crossings
598
+
599
+ sage: W.from_dowker_code([4,8,10,-14,2,-16,-18,-6,-12])
600
+ Knot represented by 9 crossings
601
+
602
+ sage: K3 = W.from_dowker_code([6,-12,2,8,-4,-10]); K3
603
+ Knot represented by 6 crossings
604
+ sage: K3.dowker_notation()
605
+ [(5, 2), (4, 9), (1, 6), (7, 8), (10, 11), (12, 3)]
606
+
607
+ .. SEEALSO:: :meth:`~sage.knots.knot.Knot.dowker_notation`
608
+
609
+ REFERENCES:
610
+
611
+ - :wikipedia:`Dowker_notation`
612
+
613
+ - http://katlas.org/wiki/DT_(Dowker-Thistlethwaite)_Codes
614
+ """
615
+ gauss = dowker_to_gauss(code)
616
+ orientations = recover_orientations(gauss)[3]
617
+ return Knot([[gauss], orientations])
618
+
619
+ def from_table(self, n, k):
620
+ """
621
+ Return a knot from its index in the Rolfsen table.
622
+
623
+ INPUT:
624
+
625
+ - ``n`` -- the crossing number
626
+ - ``k`` -- positive integer
627
+
628
+ OUTPUT: the knot `K_{n,k}` in the Rolfsen table
629
+
630
+ EXAMPLES::
631
+
632
+ sage: K1 = Knots().from_table(6,3); K1
633
+ Knot represented by 6 crossings
634
+ sage: K1.alexander_polynomial()
635
+ t^-2 - 3*t^-1 + 5 - 3*t + t^2
636
+
637
+ sage: K2 = Knots().from_table(8,4); K2
638
+ Knot represented by 9 crossings
639
+ sage: K2.determinant()
640
+ 19
641
+ sage: K2.signature()
642
+ 2
643
+
644
+ sage: K3 = Knots().from_table(10,56); K3
645
+ Knot represented by 11 crossings
646
+ sage: K3.jones_polynomial() # needs sage.symbolic
647
+ t^10 - 3*t^9 + 6*t^8 - 9*t^7 + 10*t^6 - 11*t^5 + 10*t^4 - 7*t^3
648
+ + 5*t^2 - 2*t + 1
649
+
650
+ sage: K4 = Knots().from_table(10,100)
651
+ sage: K4.genus()
652
+ 4
653
+
654
+ TESTS::
655
+
656
+ sage: Knots().from_table(6,6)
657
+ Traceback (most recent call last):
658
+ ...
659
+ ValueError: not found in the knot table
660
+
661
+ sage: Knots().from_table(12,6)
662
+ Traceback (most recent call last):
663
+ ...
664
+ ValueError: more than 10 crossings, not in the knot table
665
+
666
+ REFERENCES:
667
+
668
+ - KnotAtlas, http://katlas.math.toronto.edu/wiki/The_Rolfsen_Knot_Table
669
+ """
670
+ if n > 10:
671
+ raise ValueError('more than 10 crossings, not in the knot table')
672
+ if (n, k) in small_knots_table:
673
+ m, word = small_knots_table[(n, k)]
674
+
675
+ from sage.groups.braid import BraidGroup
676
+
677
+ G = BraidGroup(m)
678
+ return Knot(G(word))
679
+ else:
680
+ raise ValueError('not found in the knot table')
681
+
682
+ Element = Knot