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
@@ -0,0 +1,1680 @@
1
+ # sage_setup: distribution = sagemath-graphs
2
+ # sage.doctest: needs sage.graphs
3
+ """
4
+ Examples of simplicial complexes
5
+
6
+ There are two main types: manifolds and examples related to graph
7
+ theory.
8
+
9
+ For manifolds, there are functions defining the `n`-sphere for any
10
+ `n`, the torus, `n`-dimensional real projective space for any `n`, the
11
+ complex projective plane, surfaces of arbitrary genus, and some other
12
+ manifolds, all as simplicial complexes.
13
+
14
+ Aside from surfaces, this file also provides functions for
15
+ constructing some other simplicial complexes: the simplicial complex
16
+ of not-`i`-connected graphs on `n` vertices, the matching complex on n
17
+ vertices, the chessboard complex for an `n` by `i` chessboard, and
18
+ others. These provide examples of large simplicial complexes; for
19
+ example, ``simplicial_complexes.NotIConnectedGraphs(7, 2)`` has over a
20
+ million simplices.
21
+
22
+ All of these examples are accessible by typing
23
+ ``simplicial_complexes.NAME``, where ``NAME`` is the name of the example.
24
+
25
+ - :func:`BarnetteSphere`
26
+ - :func:`BrucknerGrunbaumSphere`
27
+ - :func:`ChessboardComplex`
28
+ - :func:`ComplexProjectivePlane`
29
+ - :func:`DunceHat`
30
+ - :func:`FareyMap`
31
+ - :func:`GenusSix`
32
+ - :func:`K3Surface`
33
+ - :func:`KleinBottle`
34
+ - :func:`MatchingComplex`
35
+ - :func:`MooreSpace`
36
+ - :func:`NotIConnectedGraphs`
37
+ - :func:`PoincareHomologyThreeSphere`
38
+ - :func:`QuaternionicProjectivePlane`
39
+ - :func:`RandomComplex`
40
+ - :func:`RandomTwoSphere`
41
+ - :func:`RealProjectivePlane`
42
+ - :func:`RealProjectiveSpace`
43
+ - :func:`RudinBall`
44
+ - :func:`ShiftedComplex`
45
+ - :func:`Simplex`
46
+ - :func:`Sphere`
47
+ - :func:`SumComplex`
48
+ - :func:`SurfaceOfGenus`
49
+ - :func:`Torus`
50
+ - :func:`ZieglerBall`
51
+
52
+ You can also get a list by typing ``simplicial_complexes.`` and hitting the
53
+ :kbd:`Tab` key.
54
+
55
+ EXAMPLES::
56
+
57
+ sage: S = simplicial_complexes.Sphere(2) # the 2-sphere
58
+ sage: S.homology() # needs sage.modules
59
+ {0: 0, 1: 0, 2: Z}
60
+ sage: simplicial_complexes.SurfaceOfGenus(3)
61
+ Triangulation of an orientable surface of genus 3
62
+ sage: M4 = simplicial_complexes.MooreSpace(4)
63
+ sage: M4.homology() # needs sage.modules
64
+ {0: 0, 1: C4, 2: 0}
65
+ sage: simplicial_complexes.MatchingComplex(6).homology() # needs sage.modules
66
+ {0: 0, 1: Z^16, 2: 0}
67
+ """
68
+
69
+ from .simplicial_complex import SimplicialComplex
70
+ from sage.structure.unique_representation import UniqueRepresentation
71
+ # Below we define a function Simplex to construct a simplex as a
72
+ # simplicial complex. We also need to use actual simplices as
73
+ # simplices, hence:
74
+ from .simplicial_complex import Simplex as TrueSimplex
75
+ from sage.sets.set import Set
76
+ from sage.misc.functional import is_even
77
+ from sage.combinat.subset import Subsets
78
+ import sage.misc.prandom as random
79
+ from sage.misc.superseded import deprecated_function_alias
80
+
81
+ # Miscellaneous utility functions.
82
+
83
+ # The following two functions can be used to generate the facets for
84
+ # the corresponding examples in sage.homology.examples. These take a
85
+ # few seconds to run, so the actual examples have the facets
86
+ # hard-coded. Thus the following functions are not currently used in
87
+ # the Sage library.
88
+
89
+
90
+ def facets_for_RP4():
91
+ """
92
+ Return the list of facets for a minimal triangulation of 4-dimensional
93
+ real projective space.
94
+
95
+ We use vertices numbered 1 through 16, define two facets, and define
96
+ a certain subgroup `G` of the symmetric group `S_{16}`. Then the set
97
+ of all facets is the `G`-orbit of the two given facets.
98
+
99
+ See the description in Example 3.12 in Datta [Dat2007]_.
100
+
101
+ EXAMPLES::
102
+
103
+ sage: from sage.topology.simplicial_complex_examples import facets_for_RP4
104
+ sage: A = facets_for_RP4() # long time (1 or 2 seconds)
105
+ sage: SimplicialComplex(A) == simplicial_complexes.RealProjectiveSpace(4) # long time
106
+ True
107
+ """
108
+ # Define the group:
109
+ from sage.groups.perm_gps.permgroup import PermutationGroup
110
+ g1 = '(2, 7)(4, 10)(5, 6)(11, 12)'
111
+ g2 = '(1, 2, 3, 4, 5, 10)(6, 8, 9)(11, 12, 13, 14, 15, 16)'
112
+ G = PermutationGroup([g1, g2])
113
+ # Define the two simplices:
114
+ t1 = (1, 2, 4, 5, 11)
115
+ t2 = (1, 2, 4, 11, 13)
116
+ # Apply the group elements to the simplices:
117
+ facets = []
118
+ for g in G:
119
+ d = g.dict()
120
+ for t in [t1, t2]:
121
+ new = tuple([d[j] for j in t])
122
+ if new not in facets:
123
+ facets.append(new)
124
+ return facets
125
+
126
+
127
+ def facets_for_K3():
128
+ """
129
+ Return the facets for a minimal triangulation of the K3 surface.
130
+
131
+ This is a pure simplicial complex of dimension 4 with 16
132
+ vertices and 288 facets. The facets are obtained by constructing a
133
+ few facets and a permutation group `G`, and then computing the
134
+ `G`-orbit of those facets.
135
+
136
+ See Casella and Kühnel in [CK2001]_ and Spreer and Kühnel [SK2011]_;
137
+ the construction here uses the labeling from Spreer and Kühnel.
138
+
139
+ EXAMPLES::
140
+
141
+ sage: from sage.topology.simplicial_complex_examples import facets_for_K3
142
+ sage: A = facets_for_K3() # long time (a few seconds)
143
+ sage: SimplicialComplex(A) == simplicial_complexes.K3Surface() # long time
144
+ True
145
+ """
146
+ from sage.groups.perm_gps.permgroup import PermutationGroup
147
+ G = PermutationGroup([[(1, 3, 8, 4, 9, 16, 15, 2, 14, 12, 6, 7, 13, 5, 10)],
148
+ [(1, 11, 16), (2, 10, 14), (3, 12, 13), (4, 9, 15), (5, 7, 8)]])
149
+ return ([tuple([g(i) for i in (1, 2, 3, 8, 12)]) for g in G] +
150
+ [tuple([g(i) for i in (1, 2, 5, 8, 14)]) for g in G])
151
+
152
+
153
+ def matching(A, B):
154
+ r"""
155
+ List of maximal matchings between the sets ``A`` and ``B``.
156
+
157
+ A matching is a set of pairs `(a, b) \in A \times B` where each `a` and
158
+ `b` appears in at most one pair. A maximal matching is one which is
159
+ maximal with respect to inclusion of subsets of `A \times B`.
160
+
161
+ INPUT:
162
+
163
+ - ``A``, ``B`` -- list, tuple, or indeed anything which can be
164
+ converted to a set
165
+
166
+ EXAMPLES::
167
+
168
+ sage: from sage.topology.simplicial_complex_examples import matching
169
+ sage: matching([1, 2], [3, 4])
170
+ [{(1, 3), (2, 4)}, {(1, 4), (2, 3)}]
171
+ sage: matching([0, 2], [0])
172
+ [{(0, 0)}, {(2, 0)}]
173
+ """
174
+ answer = []
175
+ if len(A) == 0 or len(B) == 0:
176
+ return [set()]
177
+ for v in A:
178
+ for w in B:
179
+ for M in matching(set(A).difference([v]), set(B).difference([w])):
180
+ new = M.union([(v, w)])
181
+ if new not in answer:
182
+ answer.append(new)
183
+ return answer
184
+
185
+
186
+ class UniqueSimplicialComplex(SimplicialComplex, UniqueRepresentation):
187
+ """
188
+ This combines :class:`SimplicialComplex` and
189
+ :class:`UniqueRepresentation`. It is intended to be used to make
190
+ standard examples of simplicial complexes unique. See :issue:`13566`.
191
+
192
+ INPUT:
193
+
194
+ - the inputs are the same as for a :class:`SimplicialComplex`,
195
+ with one addition and two exceptions. The exceptions are that
196
+ ``is_mutable`` and ``is_immutable`` are ignored: all instances
197
+ of this class are immutable. The addition:
198
+
199
+ - ``name`` -- string (optional); the string representation for this complex
200
+
201
+ EXAMPLES::
202
+
203
+ sage: from sage.topology.simplicial_complex_examples import UniqueSimplicialComplex
204
+ sage: SimplicialComplex([[0, 1]]) is SimplicialComplex([[0, 1]])
205
+ False
206
+ sage: UniqueSimplicialComplex([[0, 1]]) is UniqueSimplicialComplex([[0, 1]])
207
+ True
208
+ sage: UniqueSimplicialComplex([[0, 1]])
209
+ Simplicial complex with vertex set (0, 1) and facets {(0, 1)}
210
+ sage: UniqueSimplicialComplex([[0, 1]], name='The 1-simplex')
211
+ The 1-simplex
212
+ """
213
+ @staticmethod
214
+ def __classcall__(self, maximal_faces=None, name=None, **kwds):
215
+ """
216
+ TESTS::
217
+
218
+ sage: from sage.topology.simplicial_complex_examples import UniqueSimplicialComplex
219
+ sage: UniqueSimplicialComplex([[1, 2, 3], [0, 1, 3]]) is UniqueSimplicialComplex([(1, 2, 3), (0, 1, 3)])
220
+ True
221
+ sage: X = UniqueSimplicialComplex([[1, 2, 3], [0, 1, 3]])
222
+ sage: X is UniqueSimplicialComplex(X)
223
+ True
224
+
225
+ Testing ``from_characteristic_function``::
226
+
227
+ sage: UniqueSimplicialComplex(from_characteristic_function=(lambda x: sum(x) <= 4, range(5)))
228
+ Simplicial complex with vertex set (0, 1, 2, 3, 4) and facets {(0, 4), (0, 1, 2), (0, 1, 3)}
229
+ """
230
+ char_fcn = kwds.get('from_characteristic_function', None)
231
+ if char_fcn:
232
+ kwds['from_characteristic_function'] = (char_fcn[0], tuple(char_fcn[1]))
233
+ if maximal_faces:
234
+ # Test to see if maximal_faces is a cell complex or another
235
+ # object which can be converted to a simplicial complex:
236
+ C = None
237
+ if isinstance(maximal_faces, SimplicialComplex):
238
+ C = maximal_faces
239
+ else:
240
+ try:
241
+ C = maximal_faces._simplicial_()
242
+ except AttributeError:
243
+ if not isinstance(maximal_faces, (list, tuple, Simplex)):
244
+ # Convert it into a list (in case it is an iterable)
245
+ maximal_faces = list(maximal_faces)
246
+ if C is not None:
247
+ maximal_faces = C.facets()
248
+ # Now convert maximal_faces to a tuple of tuples, so that it is hashable.
249
+ maximal_faces = tuple(tuple(mf) for mf in maximal_faces)
250
+ return super().__classcall__(self, maximal_faces, name=name, **kwds)
251
+
252
+ def __init__(self, maximal_faces=None, name=None, **kwds):
253
+ """
254
+ TESTS::
255
+
256
+ sage: from sage.topology.simplicial_complex_examples import UniqueSimplicialComplex
257
+ sage: UniqueSimplicialComplex([[1, 2, 3], [0, 1, 3]], is_mutable=True).is_mutable()
258
+ False
259
+ """
260
+ if 'is_mutable' in kwds:
261
+ del kwds['is_mutable']
262
+ if 'is_immutable' in kwds:
263
+ del kwds['is_immutable']
264
+ self._name = name
265
+ SimplicialComplex.__init__(self, maximal_faces=maximal_faces, is_mutable=False, **kwds)
266
+
267
+ def _repr_(self):
268
+ """
269
+ Print representation.
270
+
271
+ If the argument ``name`` was specified when defining the
272
+ complex, use that. Otherwise, use the print representation
273
+ from the class :class:`SimplicialComplex`.
274
+
275
+ TESTS::
276
+
277
+ sage: from sage.topology.simplicial_complex_examples import UniqueSimplicialComplex
278
+ sage: UniqueSimplicialComplex([[0, 1]])
279
+ Simplicial complex with vertex set (0, 1) and facets {(0, 1)}
280
+ sage: UniqueSimplicialComplex([[0, 1]], name='Joe')
281
+ Joe
282
+ """
283
+ if self._name:
284
+ return self._name
285
+ return SimplicialComplex._repr_(self)
286
+
287
+ # Now the functions that produce the actual examples...
288
+
289
+
290
+ def Sphere(n):
291
+ """
292
+ A minimal triangulation of the `n`-dimensional sphere.
293
+
294
+ INPUT:
295
+
296
+ - ``n`` -- positive integer
297
+
298
+ EXAMPLES::
299
+
300
+ sage: simplicial_complexes.Sphere(2)
301
+ Minimal triangulation of the 2-sphere
302
+ sage: simplicial_complexes.Sphere(5).homology() # needs sage.modules
303
+ {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: Z}
304
+ sage: [simplicial_complexes.Sphere(n).euler_characteristic() for n in range(6)]
305
+ [2, 0, 2, 0, 2, 0]
306
+ sage: [simplicial_complexes.Sphere(n).f_vector() for n in range(6)]
307
+ [[1, 2],
308
+ [1, 3, 3],
309
+ [1, 4, 6, 4],
310
+ [1, 5, 10, 10, 5],
311
+ [1, 6, 15, 20, 15, 6],
312
+ [1, 7, 21, 35, 35, 21, 7]]
313
+ """
314
+ S = TrueSimplex(n+1)
315
+ facets = tuple(S.faces())
316
+ return UniqueSimplicialComplex(facets,
317
+ name='Minimal triangulation of the {}-sphere'.format(n))
318
+
319
+
320
+ def Simplex(n):
321
+ """
322
+ An `n`-dimensional simplex, as a simplicial complex.
323
+
324
+ INPUT:
325
+
326
+ - ``n`` -- nonnegative integer
327
+
328
+ OUTPUT: the simplicial complex consisting of the `n`-simplex
329
+ on vertices `(0, 1, ..., n)` and all of its faces.
330
+
331
+ EXAMPLES::
332
+
333
+ sage: simplicial_complexes.Simplex(3)
334
+ The 3-simplex
335
+ sage: simplicial_complexes.Simplex(5).euler_characteristic()
336
+ 1
337
+ """
338
+ return UniqueSimplicialComplex([TrueSimplex(n)],
339
+ name='The {}-simplex'.format(n))
340
+
341
+
342
+ def Torus():
343
+ r"""
344
+ A minimal triangulation of the torus.
345
+
346
+ This is a simplicial complex with 7 vertices, 21 edges and 14
347
+ faces. It is the unique triangulation of the torus with 7
348
+ vertices, and has been found by Möbius in 1861.
349
+
350
+ This is also the combinatorial structure of the Császár
351
+ polyhedron (see :wikipedia:`Császár_polyhedron`).
352
+
353
+ EXAMPLES::
354
+
355
+ sage: T = simplicial_complexes.Torus()
356
+ sage: T.homology(1) # needs sage.modules
357
+ Z x Z
358
+ sage: T.f_vector()
359
+ [1, 7, 21, 14]
360
+
361
+ TESTS::
362
+
363
+ sage: T.flip_graph().is_isomorphic(graphs.HeawoodGraph())
364
+ True
365
+
366
+ REFERENCES:
367
+
368
+ - [Lut2002]_
369
+ """
370
+ return UniqueSimplicialComplex([[0, 1, 2], [1, 2, 4], [1, 3, 4], [1, 3, 6],
371
+ [0, 1, 5], [1, 5, 6], [2, 3, 5], [2, 4, 5],
372
+ [2, 3, 6], [0, 2, 6], [0, 3, 4], [0, 3, 5],
373
+ [4, 5, 6], [0, 4, 6]],
374
+ name='Minimal triangulation of the torus')
375
+
376
+
377
+ def RealProjectivePlane():
378
+ """
379
+ A minimal triangulation of the real projective plane.
380
+
381
+ EXAMPLES::
382
+
383
+ sage: P = simplicial_complexes.RealProjectivePlane()
384
+ sage: Q = simplicial_complexes.ProjectivePlane()
385
+ sage: P == Q
386
+ True
387
+
388
+ sage: # needs sage.modules
389
+ sage: P.cohomology(1)
390
+ 0
391
+ sage: P.cohomology(2)
392
+ C2
393
+ sage: P.cohomology(1, base_ring=GF(2))
394
+ Vector space of dimension 1 over Finite Field of size 2
395
+ sage: P.cohomology(2, base_ring=GF(2))
396
+ Vector space of dimension 1 over Finite Field of size 2
397
+ """
398
+ return UniqueSimplicialComplex([[0, 1, 2], [0, 2, 3], [0, 1, 5], [0, 4, 5],
399
+ [0, 3, 4], [1, 2, 4], [1, 3, 4], [1, 3, 5],
400
+ [2, 3, 5], [2, 4, 5]],
401
+ name='Minimal triangulation of the real projective plane')
402
+
403
+
404
+ ProjectivePlane = RealProjectivePlane
405
+
406
+
407
+ def KleinBottle():
408
+ """
409
+ A minimal triangulation of the Klein bottle, as presented for example
410
+ in Davide Cervone's thesis [Cer1994]_.
411
+
412
+ EXAMPLES::
413
+
414
+ sage: simplicial_complexes.KleinBottle()
415
+ Minimal triangulation of the Klein bottle
416
+ """
417
+ return UniqueSimplicialComplex([[2, 3, 7], [1, 2, 3], [1, 3, 5], [1, 5, 7],
418
+ [1, 4, 7], [2, 4, 6], [1, 2, 6], [1, 6, 0],
419
+ [1, 4, 0], [2, 4, 0], [3, 4, 7], [3, 4, 6],
420
+ [3, 5, 6], [5, 6, 0], [2, 5, 0], [2, 5, 7]],
421
+ name='Minimal triangulation of the Klein bottle')
422
+
423
+
424
+ def SurfaceOfGenus(g, orientable=True):
425
+ """
426
+ A surface of genus `g`.
427
+
428
+ INPUT:
429
+
430
+ - ``g`` -- nonnegative integer; the desired genus
431
+
432
+ - ``orientable`` -- boolean (default: ``True``); if
433
+ ``True``, return an orientable surface, and if ``False``,
434
+ return a non-orientable surface.
435
+
436
+ In the orientable case, return a sphere if `g` is zero, and
437
+ otherwise return a `g`-fold connected sum of a torus with itself.
438
+
439
+ In the non-orientable case, raise an error if `g` is zero. If
440
+ `g` is positive, return a `g`-fold connected sum of a
441
+ real projective plane with itself.
442
+
443
+ EXAMPLES::
444
+
445
+ sage: simplicial_complexes.SurfaceOfGenus(2)
446
+ Triangulation of an orientable surface of genus 2
447
+ sage: simplicial_complexes.SurfaceOfGenus(1, orientable=False)
448
+ Triangulation of a non-orientable surface of genus 1
449
+ """
450
+ if g == 0:
451
+ if not orientable:
452
+ raise ValueError("no non-orientable surface of genus zero")
453
+ else:
454
+ return Sphere(2)
455
+ if orientable:
456
+ T = Torus()
457
+ else:
458
+ T = RealProjectivePlane()
459
+ S = T
460
+ for i in range(g-1):
461
+ S = S.connected_sum(T)
462
+ if orientable:
463
+ name_str = 'Triangulation of an orientable surface of genus {}'
464
+ else:
465
+ name_str = 'Triangulation of a non-orientable surface of genus {}'
466
+
467
+ return UniqueSimplicialComplex(S, name=name_str.format(g))
468
+
469
+
470
+ def MooreSpace(q):
471
+ r"""
472
+ Triangulation of the mod `q` Moore space.
473
+
474
+ INPUT:
475
+
476
+ - ``q`` -- integer; at least 2
477
+
478
+ This is a simplicial complex with simplices of dimension 0, 1,
479
+ and 2, such that its reduced homology is isomorphic to
480
+ `\\ZZ/q\\ZZ` in dimension 1, zero otherwise.
481
+
482
+ If `q=2`, this is the real projective plane. If `q>2`, then
483
+ construct it as follows: start with a triangle with vertices
484
+ 1, 2, 3. We take a `3q`-gon forming a `q`-fold cover of the
485
+ triangle, and we form the resulting complex as an
486
+ identification space of the `3q`-gon. To triangulate this
487
+ identification space, put `q` vertices `A_0`, ..., `A_{q-1}`,
488
+ in the interior, each of which is connected to 1, 2, 3 (two
489
+ facets each: `[1, 2, A_i]`, `[2, 3, A_i]`). Put `q` more
490
+ vertices in the interior: `B_0`, ..., `B_{q-1}`, with facets
491
+ `[3, 1, B_i]`, `[3, B_i, A_i]`, `[1, B_i, A_{i+1}]`, `[B_i,
492
+ A_i, A_{i+1}]`. Then triangulate the interior polygon with
493
+ vertices `A_0`, `A_1`, ..., `A_{q-1}`.
494
+
495
+ EXAMPLES::
496
+
497
+ sage: simplicial_complexes.MooreSpace(2)
498
+ Minimal triangulation of the real projective plane
499
+ sage: simplicial_complexes.MooreSpace(3).homology()[1] # needs sage.modules
500
+ C3
501
+ sage: simplicial_complexes.MooreSpace(4).suspension().homology()[2] # needs sage.modules
502
+ C4
503
+ sage: simplicial_complexes.MooreSpace(8)
504
+ Triangulation of the mod 8 Moore space
505
+ """
506
+ if q <= 1:
507
+ raise ValueError("the mod q Moore space is only defined if q is at least 2")
508
+ if q == 2:
509
+ return RealProjectivePlane()
510
+ facets = []
511
+ for i in range(q):
512
+ Ai = "A" + str(i)
513
+ Aiplus = "A" + str((i+1) % q)
514
+ Bi = "B" + str(i)
515
+ facets.append([1, 2, Ai])
516
+ facets.append([2, 3, Ai])
517
+ facets.append([3, 1, Bi])
518
+ facets.append([3, Bi, Ai])
519
+ facets.append([1, Bi, Aiplus])
520
+ facets.append([Bi, Ai, Aiplus])
521
+ for i in range(1, q-1):
522
+ Ai = "A" + str(i)
523
+ Aiplus = "A" + str((i+1) % q)
524
+ facets.append(["A0", Ai, Aiplus])
525
+ return UniqueSimplicialComplex(facets,
526
+ name='Triangulation of the mod {} Moore space'.format(q))
527
+
528
+
529
+ def ComplexProjectivePlane():
530
+ """
531
+ A minimal triangulation of the complex projective plane.
532
+
533
+ This was constructed by Kühnel and Banchoff [KB1983]_.
534
+
535
+ EXAMPLES::
536
+
537
+ sage: C = simplicial_complexes.ComplexProjectivePlane()
538
+ sage: C.f_vector()
539
+ [1, 9, 36, 84, 90, 36]
540
+ sage: C.homology(2) # needs sage.modules
541
+ Z
542
+ sage: C.homology(4) # needs sage.modules
543
+ Z
544
+ """
545
+ return UniqueSimplicialComplex(
546
+ [[1, 2, 4, 5, 6], [2, 3, 5, 6, 4], [3, 1, 6, 4, 5],
547
+ [1, 2, 4, 5, 9], [2, 3, 5, 6, 7], [3, 1, 6, 4, 8],
548
+ [2, 3, 6, 4, 9], [3, 1, 4, 5, 7], [1, 2, 5, 6, 8],
549
+ [3, 1, 5, 6, 9], [1, 2, 6, 4, 7], [2, 3, 4, 5, 8],
550
+ [4, 5, 7, 8, 9], [5, 6, 8, 9, 7], [6, 4, 9, 7, 8],
551
+ [4, 5, 7, 8, 3], [5, 6, 8, 9, 1], [6, 4, 9, 7, 2],
552
+ [5, 6, 9, 7, 3], [6, 4, 7, 8, 1], [4, 5, 8, 9, 2],
553
+ [6, 4, 8, 9, 3], [4, 5, 9, 7, 1], [5, 6, 7, 8, 2],
554
+ [7, 8, 1, 2, 3], [8, 9, 2, 3, 1], [9, 7, 3, 1, 2],
555
+ [7, 8, 1, 2, 6], [8, 9, 2, 3, 4], [9, 7, 3, 1, 5],
556
+ [8, 9, 3, 1, 6], [9, 7, 1, 2, 4], [7, 8, 2, 3, 5],
557
+ [9, 7, 2, 3, 6], [7, 8, 3, 1, 4], [8, 9, 1, 2, 5]],
558
+ name='Minimal triangulation of the complex projective plane')
559
+
560
+
561
+ def QuaternionicProjectivePlane():
562
+ r"""
563
+ Return a pure simplicial complex of dimension 8 with 490 facets.
564
+
565
+ .. WARNING::
566
+
567
+ This was proven to be a triangulation of the projective plane
568
+ `HP^2` over the ring of quaternions by Gorodkov in 2016 [Gor2016]_.
569
+
570
+ This simplicial complex has the same homology as `HP^2`. Its
571
+ automorphism group is isomorphic to the alternating group `A_5`
572
+ and acts transitively on vertices.
573
+
574
+ This is defined here using the description in [BK1992]_. This
575
+ article deals with three different triangulations. This procedure
576
+ returns the only one which has a transitive group of automorphisms.
577
+
578
+ EXAMPLES::
579
+
580
+ sage: HP2 = simplicial_complexes.QuaternionicProjectivePlane(); HP2 # needs sage.groups
581
+ Simplicial complex with 15 vertices and 490 facets
582
+ sage: HP2.f_vector() # needs sage.groups
583
+ [1, 15, 105, 455, 1365, 3003, 4515, 4230, 2205, 490]
584
+
585
+ Checking its automorphism group::
586
+
587
+ sage: HP2.automorphism_group().is_isomorphic(AlternatingGroup(5)) # needs sage.groups
588
+ True
589
+ """
590
+ from sage.groups.perm_gps.permgroup import PermutationGroup
591
+ P = [(1, 2, 3, 4, 5), (6, 7, 8, 9, 10), (11, 12, 13, 14, 15)]
592
+ S = [(1, 6, 11), (2, 15, 14), (3, 13, 8), (4, 7, 5), (9, 12, 10)]
593
+ start_list = [
594
+ (1, 2, 3, 6, 8, 11, 13, 14, 15), # A
595
+ (1, 3, 6, 8, 9, 10, 11, 12, 13), # B
596
+ (1, 2, 6, 9, 10, 11, 12, 14, 15), # C
597
+ (1, 2, 3, 4, 7, 9, 12, 14, 15), # D
598
+ (1, 2, 4, 7, 9, 10, 12, 13, 14), # E
599
+ (1, 2, 6, 8, 9, 10, 11, 14, 15), # F
600
+ (1, 2, 3, 4, 5, 6, 9, 11, 13), # G
601
+ (1, 3, 5, 6, 8, 9, 10, 11, 12), # H
602
+ (1, 3, 5, 6, 7, 8, 9, 10, 11), # I
603
+ (1, 2, 3, 4, 5, 7, 10, 12, 15), # J
604
+ (1, 2, 3, 7, 8, 10, 12, 13, 14), # K
605
+ (2, 5, 6, 7, 8, 9, 10, 13, 14), # M
606
+
607
+ (3, 4, 6, 7, 11, 12, 13, 14, 15), # L
608
+ (3, 4, 6, 7, 10, 12, 13, 14, 15)] # N
609
+ return UniqueSimplicialComplex([[g(index) for index in tup]
610
+ for tup in start_list
611
+ for g in PermutationGroup([P, S])])
612
+
613
+
614
+ def PoincareHomologyThreeSphere():
615
+ """
616
+ A triangulation of the Poincaré homology 3-sphere.
617
+
618
+ This is a manifold whose integral homology is identical to the
619
+ ordinary 3-sphere, but it is not simply connected. In particular,
620
+ its fundamental group is the binary icosahedral group, which has
621
+ order 120. The triangulation given here has 16 vertices and is
622
+ due to Björner and Lutz [BL2000]_.
623
+
624
+ EXAMPLES::
625
+
626
+ sage: S3 = simplicial_complexes.Sphere(3)
627
+ sage: Sigma3 = simplicial_complexes.PoincareHomologyThreeSphere()
628
+ sage: S3.homology() == Sigma3.homology() # needs sage.modules
629
+ True
630
+ sage: Sigma3.fundamental_group().cardinality() # long time # needs sage.groups
631
+ 120
632
+ """
633
+ return UniqueSimplicialComplex(
634
+ [[1, 2, 4, 9], [1, 2, 4, 15], [1, 2, 6, 14], [1, 2, 6, 15],
635
+ [1, 2, 9, 14], [1, 3, 4, 12], [1, 3, 4, 15], [1, 3, 7, 10],
636
+ [1, 3, 7, 12], [1, 3, 10, 15], [1, 4, 9, 12], [1, 5, 6, 13],
637
+ [1, 5, 6, 14], [1, 5, 8, 11], [1, 5, 8, 13], [1, 5, 11, 14],
638
+ [1, 6, 13, 15], [1, 7, 8, 10], [1, 7, 8, 11], [1, 7, 11, 12],
639
+ [1, 8, 10, 13], [1, 9, 11, 12], [1, 9, 11, 14], [1, 10, 13, 15],
640
+ [2, 3, 5, 10], [2, 3, 5, 11], [2, 3, 7, 10], [2, 3, 7, 13],
641
+ [2, 3, 11, 13], [2, 4, 9, 13], [2, 4, 11, 13], [2, 4, 11, 15],
642
+ [2, 5, 8, 11], [2, 5, 8, 12], [2, 5, 10, 12], [2, 6, 10, 12],
643
+ [2, 6, 10, 14], [2, 6, 12, 15], [2, 7, 9, 13], [2, 7, 9, 14],
644
+ [2, 7, 10, 14], [2, 8, 11, 15], [2, 8, 12, 15], [3, 4, 5, 14],
645
+ [3, 4, 5, 15], [3, 4, 12, 14], [3, 5, 10, 15], [3, 5, 11, 14],
646
+ [3, 7, 12, 13], [3, 11, 13, 14], [3, 12, 13, 14], [4, 5, 6, 7],
647
+ [4, 5, 6, 14], [4, 5, 7, 15], [4, 6, 7, 11], [4, 6, 10, 11],
648
+ [4, 6, 10, 14], [4, 7, 11, 15], [4, 8, 9, 12], [4, 8, 9, 13],
649
+ [4, 8, 10, 13], [4, 8, 10, 14], [4, 8, 12, 14], [4, 10, 11, 13],
650
+ [5, 6, 7, 13], [5, 7, 9, 13], [5, 7, 9, 15], [5, 8, 9, 12],
651
+ [5, 8, 9, 13], [5, 9, 10, 12], [5, 9, 10, 15], [6, 7, 11, 12],
652
+ [6, 7, 12, 13], [6, 10, 11, 12], [6, 12, 13, 15], [7, 8, 10, 14],
653
+ [7, 8, 11, 15], [7, 8, 14, 15], [7, 9, 14, 15], [8, 12, 14, 15],
654
+ [9, 10, 11, 12], [9, 10, 11, 16], [9, 10, 15, 16], [9, 11, 14, 16],
655
+ [9, 14, 15, 16], [10, 11, 13, 16], [10, 13, 15, 16],
656
+ [11, 13, 14, 16], [12, 13, 14, 15], [13, 14, 15, 16]],
657
+ name='Triangulation of the Poincare homology 3-sphere')
658
+
659
+
660
+ def RealProjectiveSpace(n):
661
+ r"""
662
+ A triangulation of `\Bold{R}P^n` for any `n \geq 0`.
663
+
664
+ INPUT:
665
+
666
+ - ``n`` -- integer; the dimension of the real projective space
667
+ to construct
668
+
669
+ The first few cases are pretty trivial:
670
+
671
+ - `\Bold{R}P^0` is a point.
672
+
673
+ - `\Bold{R}P^1` is a circle, triangulated as the boundary of a
674
+ single 2-simplex.
675
+
676
+ - `\Bold{R}P^2` is the real projective plane, here given its
677
+ minimal triangulation with 6 vertices, 15 edges, and 10
678
+ triangles.
679
+
680
+ - `\Bold{R}P^3`: any triangulation has at least 11 vertices by
681
+ a result of Walkup [Wal1970]_; this function returns a
682
+ triangulation with 11 vertices, as given by Lutz [Lut2005]_.
683
+
684
+ - `\Bold{R}P^4`: any triangulation has at least 16 vertices by
685
+ a result of Walkup; this function returns a triangulation
686
+ with 16 vertices as given by Lutz; see also Datta [Dat2007]_,
687
+ Example 3.12.
688
+
689
+ - `\Bold{R}P^n`: Lutz has found a triangulation of
690
+ `\Bold{R}P^5` with 24 vertices, but it does not seem to have
691
+ been published. Kühnel [Kuh1987]_ has described a triangulation of
692
+ `\Bold{R}P^n`, in general, with `2^{n+1}-1` vertices; see
693
+ also Datta, Example 3.21. This triangulation is presumably
694
+ not minimal, but it seems to be the best in the published
695
+ literature as of this writing. So this function returns it
696
+ when `n > 4`.
697
+
698
+ ALGORITHM: For `n < 4`, these are constructed explicitly by
699
+ listing the facets. For `n = 4`, this is constructed by
700
+ specifying 16 vertices, two facets, and a certain subgroup `G`
701
+ of the symmetric group `S_{16}`. Then the set of all facets
702
+ is the `G`-orbit of the two given facets. This is implemented
703
+ here by explicitly listing all of the facets; the facets
704
+ can be computed by the function :func:`~sage.homology.simplicial_complex.facets_for_RP4`, but
705
+ running the function takes a few seconds.
706
+
707
+ For `n > 4`, the construction is as follows: let `S` denote
708
+ the simplicial complex structure on the `n`-sphere given by
709
+ the first barycentric subdivision of the boundary of an
710
+ `(n+1)`-simplex. This has a simplicial antipodal action: if
711
+ `V` denotes the vertices in the boundary of the simplex, then
712
+ the vertices in its barycentric subdivision `S` correspond to
713
+ nonempty proper subsets `U` of `V`, and the antipodal action
714
+ sends any subset `U` to its complement. One can show that
715
+ modding out by this action results in a triangulation for
716
+ `\Bold{R}P^n`. To find the facets in this triangulation, find
717
+ the facets in `S`. These are identified in pairs to form
718
+ `\Bold{R}P^n`, so choose a representative from each pair: for
719
+ each facet in `S`, replace any vertex in `S` containing 0 with
720
+ its complement.
721
+
722
+ Of course these complexes increase in size pretty quickly as
723
+ `n` increases.
724
+
725
+ EXAMPLES::
726
+
727
+ sage: P3 = simplicial_complexes.RealProjectiveSpace(3)
728
+ sage: P3.f_vector()
729
+ [1, 11, 51, 80, 40]
730
+ sage: P3.homology() # needs sage.modules
731
+ {0: 0, 1: C2, 2: 0, 3: Z}
732
+ sage: P4 = simplicial_complexes.RealProjectiveSpace(4)
733
+ sage: P4.f_vector()
734
+ [1, 16, 120, 330, 375, 150]
735
+ sage: P4.homology() # long time
736
+ {0: 0, 1: C2, 2: 0, 3: C2, 4: 0}
737
+ sage: P5 = simplicial_complexes.RealProjectiveSpace(5) # long time (44s on sage.math, 2012)
738
+ sage: P5.f_vector() # long time
739
+ [1, 63, 903, 4200, 8400, 7560, 2520]
740
+
741
+ The following computation can take a long time -- over half an
742
+ hour. ::
743
+
744
+ sage: P5.homology() # not tested
745
+ {0: 0, 1: C2, 2: 0, 3: C2, 4: 0, 5: Z}
746
+ sage: simplicial_complexes.RealProjectiveSpace(2).dimension()
747
+ 2
748
+ sage: P3.dimension()
749
+ 3
750
+ sage: P4.dimension() # long time
751
+ 4
752
+ sage: P5.dimension() # long time
753
+ 5
754
+ """
755
+ if n == 0:
756
+ return Simplex(0)
757
+ if n == 1:
758
+ return Sphere(1)
759
+ if n == 2:
760
+ return RealProjectivePlane()
761
+ if n == 3:
762
+ # Minimal triangulation found by Walkup and given
763
+ # explicitly by Lutz
764
+ return UniqueSimplicialComplex(
765
+ [[1, 2, 3, 7], [1, 4, 7, 9], [2, 3, 4, 8], [2, 5, 8, 10],
766
+ [3, 6, 7, 10], [1, 2, 3, 11], [1, 4, 7, 10], [2, 3, 4, 11],
767
+ [2, 5, 9, 10], [3, 6, 8, 9], [1, 2, 6, 9], [1, 4, 8, 9],
768
+ [2, 3, 7, 8], [2, 6, 9, 10], [3, 6, 9, 10], [1, 2, 6, 11],
769
+ [1, 4, 8, 10], [2, 4, 6, 10], [3, 4, 5, 9], [4, 5, 6, 7],
770
+ [1, 2, 7, 9], [1, 5, 6, 8], [2, 4, 6, 11], [3, 4, 5, 11],
771
+ [4, 5, 6, 11], [1, 3, 5, 10], [1, 5, 6, 11], [2, 4, 8, 10],
772
+ [3, 4, 8, 9], [4, 5, 7, 9], [1, 3, 5, 11], [1, 5, 8, 10],
773
+ [2, 5, 7, 8], [3, 5, 9, 10], [4, 6, 7, 10], [1, 3, 7, 10],
774
+ [1, 6, 8, 9], [2, 5, 7, 9], [3, 6, 7, 8], [5, 6, 7, 8]],
775
+ name='Minimal triangulation of RP^3')
776
+ if n == 4:
777
+ return UniqueSimplicialComplex(
778
+ [(1, 3, 8, 12, 13), (2, 7, 8, 13, 16), (4, 8, 9, 12, 14),
779
+ (2, 6, 10, 12, 16), (5, 7, 9, 10, 13), (1, 2, 7, 8, 15),
780
+ (1, 3, 9, 11, 16), (5, 6, 8, 13, 16), (1, 3, 8, 11, 13),
781
+ (3, 4, 10, 13, 15), (4, 6, 9, 12, 15), (2, 4, 6, 11, 13),
782
+ (2, 3, 9, 12, 16), (1, 6, 9, 12, 15), (2, 5, 10, 11, 12),
783
+ (1, 7, 8, 12, 15), (2, 6, 9, 13, 16), (1, 5, 9, 11, 15),
784
+ (4, 9, 10, 13, 14), (2, 7, 8, 15, 16), (2, 3, 9, 12, 14),
785
+ (1, 6, 7, 10, 14), (2, 5, 10, 11, 15), (1, 2, 4, 13, 14),
786
+ (1, 6, 10, 14, 16), (2, 6, 9, 12, 16), (1, 3, 9, 12, 16),
787
+ (4, 5, 7, 11, 16), (5, 9, 10, 11, 15), (3, 5, 8, 12, 14),
788
+ (5, 6, 9, 13, 16), (5, 6, 9, 13, 15), (1, 3, 4, 10, 16),
789
+ (1, 6, 10, 12, 16), (2, 4, 6, 9, 13), (2, 4, 6, 9, 12),
790
+ (1, 2, 4, 11, 13), (7, 9, 10, 13, 14), (1, 7, 8, 12, 13),
791
+ (4, 6, 7, 11, 12), (3, 4, 6, 11, 13), (1, 5, 6, 9, 15),
792
+ (1, 6, 7, 14, 15), (2, 3, 7, 14, 15), (2, 6, 10, 11, 12),
793
+ (5, 7, 9, 10, 11), (1, 2, 4, 5, 14), (3, 5, 10, 13, 15),
794
+ (3, 8, 9, 12, 14), (5, 9, 10, 13, 15), (2, 6, 8, 13, 16),
795
+ (1, 2, 7, 13, 14), (1, 7, 10, 12, 13), (3, 4, 6, 13, 15),
796
+ (4, 9, 10, 13, 15), (2, 3, 10, 12, 16), (1, 2, 5, 14, 15),
797
+ (2, 6, 8, 10, 11), (1, 3, 10, 12, 13), (4, 8, 9, 12, 15),
798
+ (1, 3, 8, 9, 11), (4, 6, 7, 12, 15), (1, 8, 9, 11, 15),
799
+ (4, 5, 8, 14, 16), (1, 2, 8, 11, 13), (3, 6, 8, 11, 13),
800
+ (3, 6, 8, 11, 14), (3, 5, 8, 12, 13), (3, 7, 9, 11, 14),
801
+ (4, 6, 9, 13, 15), (2, 3, 5, 10, 12), (4, 7, 8, 15, 16),
802
+ (1, 2, 7, 14, 15), (3, 7, 9, 11, 16), (3, 6, 7, 14, 15),
803
+ (2, 6, 8, 11, 13), (4, 8, 9, 10, 14), (1, 4, 10, 13, 14),
804
+ (4, 8, 9, 10, 15), (2, 7, 9, 13, 16), (1, 6, 9, 12, 16),
805
+ (2, 3, 7, 9, 14), (4, 8, 10, 15, 16), (1, 5, 9, 11, 16),
806
+ (1, 5, 6, 14, 15), (5, 7, 9, 11, 16), (4, 5, 7, 11, 12),
807
+ (5, 7, 10, 11, 12), (2, 3, 10, 15, 16), (1, 2, 7, 8, 13),
808
+ (1, 6, 7, 10, 12), (1, 3, 10, 12, 16), (7, 9, 10, 11, 14),
809
+ (1, 7, 10, 13, 14), (1, 2, 4, 5, 11), (3, 4, 6, 7, 11),
810
+ (1, 6, 7, 12, 15), (1, 3, 4, 10, 13), (1, 4, 10, 14, 16),
811
+ (2, 4, 6, 11, 12), (5, 6, 8, 14, 16), (3, 5, 6, 8, 13),
812
+ (3, 5, 6, 8, 14), (1, 2, 8, 11, 15), (1, 4, 5, 14, 16),
813
+ (2, 3, 7, 15, 16), (8, 9, 10, 11, 14), (1, 3, 4, 11, 16),
814
+ (6, 8, 10, 14, 16), (8, 9, 10, 11, 15), (1, 3, 4, 11, 13),
815
+ (2, 4, 5, 12, 14), (2, 4, 9, 13, 14), (3, 4, 7, 11, 16),
816
+ (3, 6, 7, 11, 14), (3, 8, 9, 11, 14), (2, 8, 10, 11, 15),
817
+ (1, 3, 8, 9, 12), (4, 5, 7, 8, 16), (4, 5, 8, 12, 14),
818
+ (2, 4, 9, 12, 14), (6, 8, 10, 11, 14), (3, 5, 6, 13, 15),
819
+ (1, 4, 5, 11, 16), (3, 5, 6, 14, 15), (2, 4, 5, 11, 12),
820
+ (4, 5, 7, 8, 12), (1, 8, 9, 12, 15), (5, 7, 8, 13, 16),
821
+ (2, 3, 5, 12, 14), (3, 5, 10, 12, 13), (6, 7, 10, 11, 12),
822
+ (5, 7, 9, 13, 16), (6, 7, 10, 11, 14), (5, 7, 10, 12, 13),
823
+ (1, 2, 5, 11, 15), (1, 5, 6, 9, 16), (5, 7, 8, 12, 13),
824
+ (4, 7, 8, 12, 15), (2, 3, 5, 10, 15), (2, 6, 8, 10, 16),
825
+ (3, 4, 10, 15, 16), (1, 5, 6, 14, 16), (2, 3, 5, 14, 15),
826
+ (2, 3, 7, 9, 16), (2, 7, 9, 13, 14), (3, 4, 6, 7, 15),
827
+ (4, 8, 10, 14, 16), (3, 4, 7, 15, 16), (2, 8, 10, 15, 16)],
828
+ name='Minimal triangulation of RP^4')
829
+ if n >= 5:
830
+ # Use the construction given by Datta in Example 3.21.
831
+ V = set(range(0, n+2))
832
+ S = Sphere(n).barycentric_subdivision()
833
+ X = S.facets()
834
+ facets = set()
835
+ for f in X:
836
+ new = []
837
+ for v in f:
838
+ if 0 in v:
839
+ new.append(tuple(V.difference(v)))
840
+ else:
841
+ new.append(v)
842
+ facets.add(tuple(new))
843
+ return UniqueSimplicialComplex(list(facets),
844
+ name='Triangulation of RP^{}'.format(n))
845
+
846
+
847
+ def K3Surface():
848
+ """
849
+ Return a minimal triangulation of the K3 surface.
850
+
851
+ This is a pure simplicial complex of dimension 4 with 16 vertices
852
+ and 288 facets. It was constructed by Casella and Kühnel
853
+ in [CK2001]_. The construction here uses the labeling from
854
+ Spreer and Kühnel [SK2011]_.
855
+
856
+ EXAMPLES::
857
+
858
+ sage: K3 = simplicial_complexes.K3Surface(); K3
859
+ Minimal triangulation of the K3 surface
860
+ sage: K3.f_vector()
861
+ [1, 16, 120, 560, 720, 288]
862
+
863
+ This simplicial complex is implemented just by listing all 288
864
+ facets. The list of facets can be computed by the function
865
+ :func:`~sage.homology.simplicial_complex.facets_for_K3`, but running the function takes a few
866
+ seconds.
867
+ """
868
+ return UniqueSimplicialComplex(
869
+ [(2, 10, 13, 15, 16), (2, 8, 11, 15, 16), (2, 5, 7, 8, 10),
870
+ (1, 9, 11, 13, 14), (1, 2, 8, 10, 12), (1, 3, 5, 6, 11),
871
+ (1, 5, 6, 9, 12), (1, 2, 6, 13, 16), (1, 4, 10, 13, 14),
872
+ (1, 9, 10, 14, 15), (2, 4, 7, 8, 12), (3, 4, 6, 10, 12),
873
+ (1, 6, 7, 8, 9), (3, 4, 5, 7, 15), (1, 7, 12, 15, 16),
874
+ (4, 5, 7, 13, 16), (5, 8, 11, 12, 15), (2, 4, 7, 12, 14),
875
+ (1, 4, 5, 14, 16), (2, 5, 6, 10, 11), (1, 6, 8, 12, 14),
876
+ (5, 8, 9, 14, 16), (5, 10, 11, 12, 13), (2, 4, 8, 9, 12),
877
+ (7, 9, 12, 15, 16), (1, 2, 6, 9, 15), (1, 5, 14, 15, 16),
878
+ (2, 3, 4, 5, 9), (6, 8, 10, 11, 15), (1, 5, 8, 10, 12),
879
+ (1, 3, 7, 9, 10), (6, 7, 8, 9, 13), (1, 2, 9, 11, 15),
880
+ (2, 8, 11, 14, 16), (2, 4, 5, 13, 16), (1, 4, 8, 13, 15),
881
+ (4, 7, 8, 10, 11), (2, 3, 9, 11, 14), (2, 3, 4, 9, 13),
882
+ (2, 8, 10, 12, 13), (1, 2, 4, 11, 15), (2, 3, 9, 11, 15),
883
+ (3, 5, 10, 13, 15), (3, 4, 5, 9, 11), (6, 10, 13, 15, 16),
884
+ (8, 10, 11, 15, 16), (6, 7, 11, 13, 15), (1, 5, 7, 15, 16),
885
+ (4, 5, 7, 9, 15), (3, 4, 6, 7, 16), (2, 3, 11, 14, 16),
886
+ (3, 4, 9, 11, 13), (1, 2, 5, 14, 15), (2, 3, 9, 13, 14),
887
+ (1, 2, 5, 13, 16), (2, 3, 7, 8, 12), (2, 9, 11, 12, 14),
888
+ (1, 9, 11, 15, 16), (4, 6, 9, 14, 16), (1, 4, 9, 13, 14),
889
+ (1, 2, 3, 12, 16), (8, 11, 12, 14, 15), (2, 4, 11, 12, 14),
890
+ (1, 4, 10, 12, 13), (1, 2, 6, 7, 13), (1, 3, 6, 10, 11),
891
+ (1, 6, 8, 9, 12), (1, 4, 5, 6, 14), (3, 9, 10, 12, 15),
892
+ (5, 8, 11, 12, 16), (5, 9, 10, 14, 15), (3, 9, 12, 15, 16),
893
+ (3, 6, 8, 14, 15), (2, 4, 9, 10, 16), (5, 8, 9, 13, 15),
894
+ (2, 3, 6, 9, 15), (6, 11, 12, 14, 16), (2, 3, 10, 13, 15),
895
+ (2, 8, 9, 10, 13), (3, 4, 8, 11, 13), (3, 4, 5, 7, 13),
896
+ (5, 7, 8, 10, 14), (4, 12, 13, 14, 15), (6, 7, 10, 14, 16),
897
+ (5, 10, 11, 13, 14), (3, 4, 7, 13, 16), (6, 8, 9, 12, 13),
898
+ (1, 3, 4, 10, 14), (2, 4, 6, 11, 12), (1, 7, 9, 10, 14),
899
+ (4, 6, 8, 13, 14), (4, 9, 10, 11, 16), (3, 7, 8, 10, 16),
900
+ (5, 7, 9, 15, 16), (1, 7, 9, 11, 14), (6, 8, 10, 15, 16),
901
+ (5, 8, 9, 10, 14), (7, 8, 10, 14, 16), (2, 6, 7, 9, 11),
902
+ (7, 9, 10, 13, 15), (3, 6, 7, 10, 12), (2, 4, 6, 10, 11),
903
+ (4, 5, 8, 9, 11), (1, 2, 3, 8, 16), (3, 7, 9, 10, 12),
904
+ (1, 2, 6, 8, 14), (3, 5, 6, 13, 15), (1, 5, 6, 12, 14),
905
+ (2, 5, 7, 14, 15), (1, 5, 10, 11, 12), (3, 7, 8, 10, 11),
906
+ (1, 2, 6, 14, 15), (1, 2, 6, 8, 16), (7, 9, 10, 12, 15),
907
+ (3, 4, 6, 8, 14), (3, 7, 13, 14, 16), (2, 5, 7, 8, 14),
908
+ (6, 7, 9, 10, 14), (2, 3, 7, 12, 14), (4, 10, 12, 13, 14),
909
+ (2, 5, 6, 11, 13), (4, 5, 6, 7, 16), (1, 3, 12, 13, 16),
910
+ (1, 4, 11, 15, 16), (1, 3, 4, 6, 10), (1, 10, 11, 12, 13),
911
+ (6, 9, 11, 12, 14), (1, 4, 7, 8, 15), (5, 8, 9, 10, 13),
912
+ (1, 2, 5, 7, 15), (1, 7, 12, 13, 16), (3, 11, 13, 14, 16),
913
+ (1, 2, 5, 7, 13), (4, 7, 8, 9, 15), (1, 5, 6, 10, 11),
914
+ (6, 7, 10, 13, 15), (3, 4, 7, 14, 15), (7, 11, 13, 14, 16),
915
+ (3, 4, 10, 12, 14), (3, 6, 8, 10, 16), (2, 7, 8, 14, 16),
916
+ (2, 3, 4, 5, 13), (5, 8, 12, 13, 15), (4, 6, 9, 13, 14),
917
+ (2, 4, 5, 6, 12), (1, 3, 7, 8, 9), (8, 11, 12, 14, 16),
918
+ (1, 7, 12, 13, 15), (8, 12, 13, 14, 15), (2, 8, 9, 12, 13),
919
+ (4, 6, 10, 12, 15), (2, 8, 11, 14, 15), (2, 6, 9, 11, 12),
920
+ (8, 9, 10, 11, 16), (2, 3, 6, 13, 15), (2, 3, 12, 15, 16),
921
+ (1, 3, 5, 9, 12), (2, 5, 6, 9, 12), (2, 10, 12, 13, 14),
922
+ (2, 6, 13, 15, 16), (2, 3, 11, 15, 16), (3, 5, 6, 8, 15),
923
+ (2, 4, 5, 9, 12), (5, 6, 8, 11, 15), (6, 8, 12, 13, 14),
924
+ (1, 2, 3, 8, 12), (1, 4, 7, 8, 11), (3, 5, 7, 14, 15),
925
+ (3, 5, 7, 13, 14), (1, 7, 10, 11, 14), (6, 7, 11, 12, 15),
926
+ (3, 4, 6, 7, 12), (1, 2, 4, 7, 11), (6, 9, 10, 14, 16),
927
+ (4, 10, 12, 15, 16), (5, 6, 7, 12, 16), (3, 9, 11, 13, 14),
928
+ (5, 9, 14, 15, 16), (4, 5, 6, 7, 12), (1, 3, 9, 10, 15),
929
+ (4, 7, 8, 9, 12), (5, 9, 10, 13, 15), (1, 3, 8, 13, 16),
930
+ (2, 9, 12, 13, 14), (6, 7, 10, 12, 15), (2, 6, 8, 14, 15),
931
+ (3, 5, 6, 8, 11), (3, 4, 7, 12, 14), (1, 3, 10, 14, 15),
932
+ (7, 11, 12, 13, 16), (3, 11, 12, 13, 16), (3, 4, 5, 8, 15),
933
+ (2, 4, 7, 8, 10), (2, 4, 7, 14, 15), (1, 2, 10, 12, 16),
934
+ (1, 6, 8, 13, 16), (1, 7, 8, 13, 15), (3, 9, 11, 15, 16),
935
+ (4, 6, 10, 11, 15), (2, 4, 11, 14, 15), (1, 3, 8, 9, 12),
936
+ (1, 3, 6, 14, 15), (2, 4, 5, 6, 10), (1, 4, 9, 14, 16),
937
+ (5, 7, 9, 12, 16), (1, 3, 7, 10, 11), (7, 8, 9, 13, 15),
938
+ (3, 5, 10, 14, 15), (1, 4, 10, 12, 16), (3, 4, 5, 8, 11),
939
+ (1, 2, 6, 7, 9), (1, 3, 11, 12, 13), (1, 5, 7, 13, 16),
940
+ (5, 7, 10, 11, 14), (2, 10, 12, 15, 16), (3, 6, 7, 10, 16),
941
+ (1, 2, 5, 8, 10), (4, 10, 11, 15, 16), (5, 8, 10, 12, 13),
942
+ (3, 6, 8, 10, 11), (4, 5, 7, 9, 12), (6, 7, 11, 12, 16),
943
+ (3, 5, 9, 11, 16), (8, 9, 10, 14, 16), (3, 4, 6, 8, 16),
944
+ (1, 10, 11, 13, 14), (2, 9, 10, 13, 16), (1, 2, 5, 8, 14),
945
+ (2, 4, 5, 10, 16), (1, 2, 7, 9, 11), (1, 3, 5, 6, 9),
946
+ (5, 7, 11, 13, 14), (3, 5, 10, 13, 14), (2, 4, 8, 9, 10),
947
+ (4, 11, 12, 14, 15), (2, 3, 7, 14, 16), (3, 4, 8, 13, 16),
948
+ (6, 7, 9, 11, 14), (5, 6, 11, 13, 15), (4, 5, 6, 14, 16),
949
+ (3, 4, 8, 14, 15), (4, 5, 8, 9, 15), (1, 4, 8, 11, 13),
950
+ (5, 6, 12, 14, 16), (2, 3, 10, 12, 14), (1, 2, 5, 10, 16),
951
+ (2, 5, 7, 10, 11), (2, 6, 7, 11, 13), (1, 4, 5, 10, 16),
952
+ (2, 6, 8, 15, 16), (2, 3, 10, 12, 15), (7, 11, 12, 13, 15),
953
+ (1, 3, 8, 11, 13), (4, 8, 9, 10, 11), (1, 9, 14, 15, 16),
954
+ (1, 3, 6, 9, 15), (6, 9, 12, 13, 14), (2, 3, 10, 13, 14),
955
+ (2, 5, 7, 11, 13), (2, 3, 5, 6, 13), (4, 6, 8, 13, 16),
956
+ (6, 7, 9, 10, 13), (5, 8, 12, 14, 16), (4, 6, 9, 13, 16),
957
+ (5, 8, 9, 11, 16), (2, 3, 5, 6, 9), (1, 3, 5, 11, 12),
958
+ (3, 7, 8, 9, 12), (4, 6, 11, 12, 15), (3, 5, 9, 12, 16),
959
+ (5, 11, 12, 13, 15), (1, 3, 4, 6, 14), (3, 5, 11, 12, 16),
960
+ (1, 5, 8, 12, 14), (4, 8, 13, 14, 15), (1, 3, 7, 8, 11),
961
+ (6, 9, 10, 13, 16), (2, 4, 9, 13, 16), (1, 6, 7, 8, 13),
962
+ (1, 4, 12, 13, 15), (2, 4, 7, 10, 11), (1, 4, 9, 11, 13),
963
+ (6, 7, 11, 14, 16), (1, 4, 9, 11, 16), (1, 4, 12, 15, 16),
964
+ (1, 2, 4, 7, 15), (2, 3, 7, 8, 16), (1, 4, 5, 6, 10)],
965
+ name='Minimal triangulation of the K3 surface')
966
+
967
+
968
+ def BarnetteSphere():
969
+ r"""
970
+ Return Barnette's triangulation of the 3-sphere.
971
+
972
+ This is a pure simplicial complex of dimension 3 with 8
973
+ vertices and 19 facets, which is a non-polytopal triangulation
974
+ of the 3-sphere. It was constructed by Barnette in
975
+ [Bar1970]_. The construction here uses the labeling from De
976
+ Loera, Rambau and Santos [DLRS2010]_. Another reference is chapter
977
+ III.4 of Ewald [Ewa1996]_.
978
+
979
+ EXAMPLES::
980
+
981
+ sage: BS = simplicial_complexes.BarnetteSphere(); BS
982
+ Barnette's triangulation of the 3-sphere
983
+ sage: BS.f_vector()
984
+ [1, 8, 27, 38, 19]
985
+
986
+ TESTS:
987
+
988
+ Checks that this is indeed the same Barnette Sphere as the one
989
+ given on page 87 of [Ewa1996]_.::
990
+
991
+ sage: BS2 = SimplicialComplex([[1, 2, 3, 4], [3, 4, 5, 6], [1, 2, 5, 6],
992
+ ....: [1, 2, 4, 7], [1, 3, 4, 7], [3, 4, 6, 7],
993
+ ....: [3, 5, 6, 7], [1, 2, 5, 7], [2, 5, 6, 7],
994
+ ....: [2, 4, 6, 7], [1, 2, 3, 8], [2, 3, 4, 8],
995
+ ....: [3, 4, 5, 8], [4, 5, 6, 8], [1, 2, 6, 8],
996
+ ....: [1, 5, 6, 8], [1, 3, 5, 8], [2, 4, 6, 8],
997
+ ....: [1, 3, 5, 7]])
998
+ sage: BS.is_isomorphic(BS2)
999
+ True
1000
+ """
1001
+ return UniqueSimplicialComplex([(1, 2, 4, 5), (2, 3, 5, 6), (1, 3, 4, 6),
1002
+ (1, 2, 3, 7), (4, 5, 6, 7), (1, 2, 4, 7),
1003
+ (2, 4, 5, 7), (2, 3, 5, 7), (3, 5, 6, 7),
1004
+ (3, 1, 6, 7), (1, 6, 4, 7), (1, 2, 3, 8),
1005
+ (4, 5, 6, 8), (1, 2, 5, 8), (1, 4, 5, 8),
1006
+ (2, 3, 6, 8), (2, 5, 6, 8), (3, 1, 4, 8),
1007
+ (3, 6, 4, 8)],
1008
+ name="Barnette's triangulation of the 3-sphere")
1009
+
1010
+
1011
+ def BrucknerGrunbaumSphere():
1012
+ r"""
1013
+ Return Bruckner and Grunbaum's triangulation of the 3-sphere.
1014
+
1015
+ This is a pure simplicial complex of dimension 3 with 8
1016
+ vertices and 20 facets, which is a non-polytopal triangulation
1017
+ of the 3-sphere. It appeared first in [Br1910]_ and was studied in
1018
+ [GrS1967]_.
1019
+
1020
+ It is defined here as the link of any vertex in the unique minimal
1021
+ triangulation of the complex projective plane, see chapter 4 of
1022
+ [Kuh1995]_.
1023
+
1024
+ EXAMPLES::
1025
+
1026
+ sage: BGS = simplicial_complexes.BrucknerGrunbaumSphere(); BGS
1027
+ Bruckner and Grunbaum's triangulation of the 3-sphere
1028
+ sage: BGS.f_vector()
1029
+ [1, 8, 28, 40, 20]
1030
+ """
1031
+ # X = ComplexProjectivePlane().link([9])
1032
+ # return UniqueSimplicialComplex(X.facets(),
1033
+ # name="Bruckner and Grunbaum's triangulation of the 3-sphere")
1034
+ return UniqueSimplicialComplex(ComplexProjectivePlane().link([9]),
1035
+ name="Bruckner and Grunbaum's triangulation of the 3-sphere")
1036
+
1037
+ ###############################################################
1038
+ # examples from graph theory:
1039
+
1040
+
1041
+ def NotIConnectedGraphs(n, i):
1042
+ """
1043
+ The simplicial complex of all graphs on `n` vertices which are
1044
+ not `i`-connected.
1045
+
1046
+ Fix an integer `n>0` and consider the set of graphs on `n`
1047
+ vertices. View each graph as its set of edges, so it is a
1048
+ subset of a set of size `n` choose 2. A graph is
1049
+ `i`-connected if, for any `j<i`, if any `j` vertices are
1050
+ removed along with the edges emanating from them, then the
1051
+ graph remains connected. Now fix `i`: it is clear that if `G`
1052
+ is not `i`-connected, then the same is true for any graph
1053
+ obtained from `G` by deleting edges. Thus the set of all
1054
+ graphs which are not `i`-connected, viewed as a set of subsets
1055
+ of the `n` choose 2 possible edges, is closed under taking
1056
+ subsets, and thus forms a simplicial complex. This function
1057
+ produces that simplicial complex.
1058
+
1059
+ INPUT:
1060
+
1061
+ - ``n``, ``i`` -- nonnegative integers with `i` at most `n`
1062
+
1063
+ See Dumas et al. [DHSW2003]_ for information on computing its homology
1064
+ by computer, and see Babson et al. [BBLSW1999]_ for theory. For
1065
+ example, Babson et al. show that when `i=2`, the reduced homology of
1066
+ this complex is nonzero only in dimension `2n-5`, where it is
1067
+ free abelian of rank `(n-2)!`.
1068
+
1069
+ EXAMPLES::
1070
+
1071
+ sage: NICG52 = simplicial_complexes.NotIConnectedGraphs(5, 2)
1072
+ sage: NICG52.f_vector()
1073
+ [1, 10, 45, 120, 210, 240, 140, 20]
1074
+ sage: NICG52.homology(5).ngens() # needs sage.modules
1075
+ 6
1076
+ """
1077
+ G_list = range(1, n+1)
1078
+ G_vertices = Set(G_list)
1079
+ E_list = []
1080
+ for w in G_list:
1081
+ for v in range(1, w):
1082
+ E_list.append((v, w))
1083
+ E = Set(E_list)
1084
+ facets = []
1085
+ i_minus_one_sets = list(G_vertices.subsets(size=i-1))
1086
+ for A in i_minus_one_sets:
1087
+ G_minus_A = G_vertices.difference(A)
1088
+ for B in G_minus_A.subsets():
1089
+ if len(B) > 0 and len(B) < len(G_minus_A):
1090
+ C = G_minus_A.difference(B)
1091
+ facet = E
1092
+ for v in B:
1093
+ for w in C:
1094
+ bad_edge = (min(v, w), max(v, w))
1095
+ facet = facet.difference(Set([bad_edge]))
1096
+ facets.append(facet)
1097
+ return UniqueSimplicialComplex(facets, name='Simplicial complex of not {}-connected graphs on {} vertices'.format(i, n))
1098
+
1099
+
1100
+ def MatchingComplex(n):
1101
+ """
1102
+ The matching complex of graphs on `n` vertices.
1103
+
1104
+ Fix an integer `n>0` and consider a set `V` of `n` vertices.
1105
+ A 'partial matching' on `V` is a graph formed by edges so that
1106
+ each vertex is in at most one edge. If `G` is a partial
1107
+ matching, then so is any graph obtained by deleting edges from
1108
+ `G`. Thus the set of all partial matchings on `n` vertices,
1109
+ viewed as a set of subsets of the `n` choose 2 possible edges,
1110
+ is closed under taking subsets, and thus forms a simplicial
1111
+ complex called the 'matching complex'. This function produces
1112
+ that simplicial complex.
1113
+
1114
+ INPUT:
1115
+
1116
+ - ``n`` -- positive integer
1117
+
1118
+ See Dumas et al. [DHSW2003]_ for information on computing its homology
1119
+ by computer, and see Wachs [Wac2003]_ for an expository article about
1120
+ the theory. For example, the homology of these complexes seems to
1121
+ have only mod 3 torsion, and this has been proved for the
1122
+ bottom non-vanishing homology group for the matching complex `M_n`.
1123
+
1124
+ EXAMPLES::
1125
+
1126
+ sage: M = simplicial_complexes.MatchingComplex(7)
1127
+ sage: H = M.homology(); H # needs sage.modules
1128
+ {0: 0, 1: C3, 2: Z^20}
1129
+ sage: H[2].ngens() # needs sage.modules
1130
+ 20
1131
+ sage: M8 = simplicial_complexes.MatchingComplex(8)
1132
+ sage: M8.homology(2) # long time (6s on sage.math, 2012), needs sage.modules
1133
+ Z^132
1134
+ """
1135
+ G_vertices = Set(range(1, n+1))
1136
+ facets = []
1137
+ if is_even(n):
1138
+ half = int(n/2)
1139
+ half_n_sets = list(G_vertices.subsets(size=half))
1140
+ else:
1141
+ half = int((n-1)/2)
1142
+ half_n_sets = list(G_vertices.subsets(size=half))
1143
+ for X in half_n_sets:
1144
+ Xcomp = G_vertices.difference(X)
1145
+ if is_even(n):
1146
+ if 1 in X:
1147
+ A = X
1148
+ B = Xcomp
1149
+ else:
1150
+ A = Xcomp
1151
+ B = X
1152
+ for M in matching(A, B):
1153
+ facet = []
1154
+ for pair in M:
1155
+ facet.append(tuple(sorted(pair)))
1156
+ facets.append(facet)
1157
+ else:
1158
+ for w in Xcomp:
1159
+ if 1 in X or (w == 1 and 2 in X):
1160
+ A = X
1161
+ B = Xcomp.difference([w])
1162
+ else:
1163
+ B = X
1164
+ A = Xcomp.difference([w])
1165
+ for M in matching(A, B):
1166
+ facet = []
1167
+ for pair in M:
1168
+ facet.append(tuple(sorted(pair)))
1169
+ facets.append(facet)
1170
+ return UniqueSimplicialComplex(facets, name='Matching complex on {} vertices'.format(n))
1171
+
1172
+
1173
+ def ChessboardComplex(n, i):
1174
+ r"""
1175
+ The chessboard complex for an `n \times i` chessboard.
1176
+
1177
+ Fix integers `n, i > 0` and consider sets `V` of `n` vertices
1178
+ and `W` of `i` vertices. A 'partial matching' between `V` and
1179
+ `W` is a graph formed by edges `(v, w)` with `v \in V` and `w
1180
+ \in W` so that each vertex is in at most one edge. If `G` is
1181
+ a partial matching, then so is any graph obtained by deleting
1182
+ edges from `G`. Thus the set of all partial matchings on `V`
1183
+ and `W`, viewed as a set of subsets of the `n+i` choose 2
1184
+ possible edges, is closed under taking subsets, and thus forms
1185
+ a simplicial complex called the 'chessboard complex'. This
1186
+ function produces that simplicial complex. (It is called the
1187
+ chessboard complex because such graphs also correspond to ways
1188
+ of placing rooks on an `n` by `i` chessboard so that none of
1189
+ them are attacking each other.)
1190
+
1191
+ INPUT:
1192
+
1193
+ - ``n``, ``i`` -- positive integers
1194
+
1195
+ See Dumas et al. [DHSW2003]_ for information on computing its homology
1196
+ by computer, and see Wachs [Wac2003]_ for an expository article about
1197
+ the theory.
1198
+
1199
+ EXAMPLES::
1200
+
1201
+ sage: C = simplicial_complexes.ChessboardComplex(5, 5)
1202
+ sage: C.f_vector()
1203
+ [1, 25, 200, 600, 600, 120]
1204
+ sage: simplicial_complexes.ChessboardComplex(3, 3).homology() # needs sage.modules
1205
+ {0: 0, 1: Z x Z x Z x Z, 2: 0}
1206
+ """
1207
+ A = range(n)
1208
+ B = range(i)
1209
+ E_dict = {}
1210
+ index = 0
1211
+ for v in A:
1212
+ for w in B:
1213
+ E_dict[(v, w)] = index
1214
+ index += 1
1215
+ facets = []
1216
+ for M in matching(A, B):
1217
+ facet = []
1218
+ for pair in M:
1219
+ facet.append(E_dict[pair])
1220
+ facets.append(facet)
1221
+ return UniqueSimplicialComplex(facets, name='Chessboard complex for an {}x{} chessboard'.format(n, i))
1222
+
1223
+
1224
+ def RandomComplex(n, d, p=0.5):
1225
+ """
1226
+ A random `d`-dimensional simplicial complex on `n` vertices.
1227
+
1228
+ INPUT:
1229
+
1230
+ - ``n`` -- number of vertices
1231
+
1232
+ - ``d`` -- dimension of the complex
1233
+
1234
+ - ``p`` -- floating point number between 0 and 1 (default: 0.5)
1235
+
1236
+ A random `d`-dimensional simplicial complex on `n` vertices,
1237
+ as defined for example by Meshulam and Wallach [MW2009]_, is
1238
+ constructed as follows: take `n` vertices and include all of
1239
+ the simplices of dimension strictly less than `d`, and then for each
1240
+ possible simplex of dimension `d`, include it with probability `p`.
1241
+
1242
+ EXAMPLES::
1243
+
1244
+ sage: X = simplicial_complexes.RandomComplex(6, 2); X
1245
+ Random 2-dimensional simplicial complex on 6 vertices
1246
+ sage: len(list(X.vertices()))
1247
+ 6
1248
+
1249
+ If `d` is too large (if `d+1 > n`, so that there are no
1250
+ `d`-dimensional simplices), then return the simplicial complex
1251
+ with a single `(n+1)`-dimensional simplex::
1252
+
1253
+ sage: simplicial_complexes.RandomComplex(6, 12)
1254
+ The 5-simplex
1255
+ """
1256
+ if d+1 > n:
1257
+ return Simplex(n-1)
1258
+ else:
1259
+ vertices = range(n)
1260
+ facets = Subsets(vertices, d).list()
1261
+ maybe = Subsets(vertices, d+1)
1262
+ facets.extend([f for f in maybe if random.random() <= p])
1263
+ return UniqueSimplicialComplex(facets,
1264
+ name='Random {}-dimensional simplicial complex on {} vertices'.format(d, n))
1265
+
1266
+
1267
+ def SumComplex(n, A):
1268
+ r"""
1269
+ The sum complexes of Linial, Meshulam, and Rosenthal [LMR2010]_.
1270
+
1271
+ If `k+1` is the cardinality of `A`, then this returns a
1272
+ `k`-dimensional simplicial complex `X_A` with vertices
1273
+ `\ZZ/(n)`, and facets given by all `k+1`-tuples `(x_0, x_1,
1274
+ ..., x_k)` such that the sum `\sum x_i` is in `A`. See the
1275
+ paper by Linial, Meshulam, and Rosenthal [LMR2010]_, in which
1276
+ they prove various results about these complexes; for example,
1277
+ if `n` is prime, then `X_A` is rationally acyclic, and if in
1278
+ addition `A` forms an arithmetic progression in `\ZZ/(n)`,
1279
+ then `X_A` is `\ZZ`-acyclic. Throughout their paper, they
1280
+ assume that `n` and `k` are relatively prime, but the
1281
+ construction makes sense in general.
1282
+
1283
+ In addition to the results from the cited paper, these
1284
+ complexes can have large torsion, given the number of
1285
+ vertices; for example, if `n=10`, and `A=\{0, 1, 2, 3, 6\}`, then
1286
+ `H_3(X_A)` is cyclic of order 2728, and there is a
1287
+ 4-dimensional complex on 13 vertices with `H_3` having a
1288
+ cyclic summand of order
1289
+
1290
+ .. MATH::
1291
+
1292
+ 706565607945 = 3 \cdot 5 \cdot 53 \cdot 79 \cdot 131
1293
+ \cdot 157 \cdot 547.
1294
+
1295
+ See the examples.
1296
+
1297
+ INPUT:
1298
+
1299
+ - ``n`` -- positive integer
1300
+
1301
+ - ``A`` -- a subset of `\ZZ/(n)`
1302
+
1303
+ EXAMPLES::
1304
+
1305
+ sage: S = simplicial_complexes.SumComplex(10, [0, 1, 2, 3, 6]); S
1306
+ Sum complex on vertices Z/10Z associated to {0, 1, 2, 3, 6}
1307
+ sage: S.homology() # needs sage.modules
1308
+ {0: 0, 1: 0, 2: 0, 3: C2728, 4: 0}
1309
+ sage: factor(2728)
1310
+ 2^3 * 11 * 31
1311
+
1312
+ sage: S = simplicial_complexes.SumComplex(11, [0, 1, 3]); S
1313
+ Sum complex on vertices Z/11Z associated to {0, 1, 3}
1314
+ sage: S.homology(1) # needs sage.modules
1315
+ C23
1316
+ sage: S = simplicial_complexes.SumComplex(11, [0, 1, 2, 3, 4, 7]); S
1317
+ Sum complex on vertices Z/11Z associated to {0, 1, 2, 3, 4, 7}
1318
+ sage: S.homology() # long time # needs sage.modules
1319
+ {0: 0, 1: 0, 2: 0, 3: 0, 4: C645679, 5: 0}
1320
+ sage: factor(645679)
1321
+ 23 * 67 * 419
1322
+
1323
+ sage: S = simplicial_complexes.SumComplex(13, [0, 1, 3]); S
1324
+ Sum complex on vertices Z/13Z associated to {0, 1, 3}
1325
+ sage: S.homology(1) # needs sage.modules
1326
+ C159
1327
+ sage: factor(159)
1328
+ 3 * 53
1329
+ sage: S = simplicial_complexes.SumComplex(13, [0, 1, 2, 5]); S
1330
+ Sum complex on vertices Z/13Z associated to {0, 1, 2, 5}
1331
+ sage: S.homology() # long time # needs sage.modules
1332
+ {0: 0, 1: 0, 2: C146989209, 3: 0}
1333
+ sage: factor(1648910295)
1334
+ 3^2 * 5 * 53 * 521 * 1327
1335
+ sage: S = simplicial_complexes.SumComplex(13, [0, 1, 2, 3, 5]); S
1336
+ Sum complex on vertices Z/13Z associated to {0, 1, 2, 3, 5}
1337
+ sage: S.homology() # long time # needs sage.modules
1338
+ {0: 0, 1: 0, 2: 0, 3: C3 x C237 x C706565607945, 4: 0}
1339
+ sage: factor(706565607945) # needs sage.libs.pari
1340
+ 3 * 5 * 53 * 79 * 131 * 157 * 547
1341
+
1342
+ sage: S = simplicial_complexes.SumComplex(17, [0, 1, 4]); S
1343
+ Sum complex on vertices Z/17Z associated to {0, 1, 4}
1344
+ sage: S.homology(1) # needs sage.modules
1345
+ C140183
1346
+ sage: factor(140183)
1347
+ 103 * 1361
1348
+ sage: S = simplicial_complexes.SumComplex(19, [0, 1, 4]); S
1349
+ Sum complex on vertices Z/19Z associated to {0, 1, 4}
1350
+ sage: S.homology(1) # needs sage.modules
1351
+ C5670599
1352
+ sage: factor(5670599)
1353
+ 11 * 191 * 2699
1354
+ sage: S = simplicial_complexes.SumComplex(31, [0, 1, 4]); S
1355
+ Sum complex on vertices Z/31Z associated to {0, 1, 4}
1356
+ sage: S.homology(1) # long time # needs sage.modules
1357
+ C5 x C5 x C5 x C5 x C26951480558170926865
1358
+ sage: factor(26951480558170926865) # needs sage.libs.pari
1359
+ 5 * 311 * 683 * 1117 * 11657 * 1948909
1360
+ """
1361
+ from sage.rings.finite_rings.integer_mod_ring import Integers
1362
+ Zn = Integers(n)
1363
+ A = frozenset([Zn(x) for x in A])
1364
+ facets = []
1365
+ for f in Set(Zn).subsets(len(A)):
1366
+ if sum(f) in A:
1367
+ facets.append(tuple(f))
1368
+ return UniqueSimplicialComplex(facets, name='Sum complex on vertices Z/{}Z associated to {}'.format(n, Set(A)))
1369
+
1370
+
1371
+ def RandomTwoSphere(n):
1372
+ r"""
1373
+ Return a random triangulation of the 2-dimensional sphere with `n`
1374
+ vertices.
1375
+
1376
+ INPUT:
1377
+
1378
+ - ``n`` -- integer
1379
+
1380
+ OUTPUT:
1381
+
1382
+ A random triangulation of the sphere chosen uniformly among
1383
+ the *rooted* triangulations on `n` vertices. Because some
1384
+ triangulations have nontrivial automorphism groups, this may
1385
+ not be equal to the uniform distribution among unrooted
1386
+ triangulations.
1387
+
1388
+ ALGORITHM:
1389
+
1390
+ The algorithm is taken from [PS2006]_, section 2.1.
1391
+
1392
+ Starting from a planar tree (represented by its contour as a
1393
+ sequence of vertices), one first performs local closures, until no
1394
+ one is possible. A local closure amounts to replace in the cyclic
1395
+ contour word a sequence ``in1, in2, in3, lf, in3`` by
1396
+ ``in1, in3``. After all local closures are done, one has reached
1397
+ the partial closure, as in [PS2006]_, figure 5 (a).
1398
+
1399
+ Then one has to perform complete closure by adding two more
1400
+ vertices, in order to reach the situation of [PS2006]_, figure 5
1401
+ (b). For this, it is necessary to find inside the final contour
1402
+ one of the two subsequences ``lf, in, lf``.
1403
+
1404
+ At every step of the algorithm, newly created triangles are added
1405
+ in a simplicial complex.
1406
+
1407
+ This algorithm is implemented in
1408
+ :meth:`~sage.graphs.generators.random.RandomTriangulation`, which
1409
+ creates an embedded graph. The triangles of the simplicial
1410
+ complex are recovered from this embedded graph.
1411
+
1412
+ EXAMPLES::
1413
+
1414
+ sage: G = simplicial_complexes.RandomTwoSphere(6); G
1415
+ Simplicial complex with vertex set (0, 1, 2, 3, 4, 5) and 8 facets
1416
+ sage: G.homology() # needs sage.modules
1417
+ {0: 0, 1: 0, 2: Z}
1418
+ sage: G.is_pure()
1419
+ True
1420
+ sage: fg = G.flip_graph(); fg
1421
+ Graph on 8 vertices
1422
+ sage: fg.is_planar() and fg.is_regular(3) # needs planarity
1423
+ True
1424
+ """
1425
+ from sage.graphs.generators.random import RandomTriangulation
1426
+
1427
+ graph = RandomTriangulation(n)
1428
+
1429
+ graph = graph.relabel(inplace=False)
1430
+ triangles = [(u, v, w) for u, L in graph.get_embedding().items()
1431
+ for v, w in zip(L, L[1:] + [L[0]]) if u < v and u < w]
1432
+
1433
+ return SimplicialComplex(triangles, maximality_check=False)
1434
+
1435
+
1436
+ def ShiftedComplex(generators):
1437
+ r"""
1438
+ Return the smallest shifted simplicial complex containing ``generators``
1439
+ as faces.
1440
+
1441
+ Let `V` be a set of vertices equipped with a total order. The
1442
+ 'componentwise partial ordering' on k-subsets of `V` is defined as
1443
+ follows: if `A = \{a_1 < \cdots < a_k\}` and `B = \{b_1 < \cdots < b_k\}`,
1444
+ then `A \leq_C B` iff `a_i \leq b_i` for all `i`. A simplicial complex
1445
+ `X` on vertex set `[n]` is *shifted* if its faces form an order ideal
1446
+ under the componentwise partial ordering, i.e., if `B \in X` and
1447
+ `A \leq_C B` then `A \in X`. Shifted complexes of dimension 1 are also
1448
+ known as threshold graphs.
1449
+
1450
+ .. NOTE::
1451
+
1452
+ This method assumes that `V` consists of positive integers
1453
+ with the natural ordering.
1454
+
1455
+ INPUT:
1456
+
1457
+ - ``generators`` -- list of generators of the order ideal, which may
1458
+ be lists, tuples or simplices
1459
+
1460
+ EXAMPLES::
1461
+
1462
+ sage: # needs sage.combinat
1463
+ sage: X = simplicial_complexes.ShiftedComplex([Simplex([1, 6]), (2, 4), [8]])
1464
+ sage: sorted(X.facets())
1465
+ [(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, 3), (2, 4), (7,), (8,)]
1466
+ sage: X = simplicial_complexes.ShiftedComplex([[2, 3, 5]])
1467
+ sage: sorted(X.facets())
1468
+ [(1, 2, 3), (1, 2, 4), (1, 2, 5), (1, 3, 4), (1, 3, 5), (2, 3, 4), (2, 3, 5)]
1469
+ sage: X = simplicial_complexes.ShiftedComplex([[1, 3, 5], [2, 6]])
1470
+ sage: sorted(X.facets())
1471
+ [(1, 2, 3), (1, 2, 4), (1, 2, 5), (1, 3, 4), (1, 3, 5), (1, 6), (2, 6)]
1472
+ """
1473
+ from sage.combinat.partition import Partitions
1474
+ Facets = []
1475
+ for _G in generators:
1476
+ G = sorted(_G, reverse=True)
1477
+ L = len(G)
1478
+ for k in range(L * (L + 1) // 2, sum(G) + 1):
1479
+ for P in Partitions(k, length=L, max_slope=-1, outer=G):
1480
+ Facets.append(list(reversed(P)))
1481
+ return SimplicialComplex(Facets)
1482
+
1483
+
1484
+ def RudinBall():
1485
+ r"""
1486
+ Return the non-shellable ball constructed by Rudin.
1487
+
1488
+ This complex is a non-shellable triangulation of the 3-ball
1489
+ with 14 vertices and 41 facets, constructed by Rudin in
1490
+ [Rud1958]_.
1491
+
1492
+ EXAMPLES::
1493
+
1494
+ sage: R = simplicial_complexes.RudinBall(); R
1495
+ Rudin ball
1496
+ sage: R.f_vector()
1497
+ [1, 14, 66, 94, 41]
1498
+ sage: R.homology() # needs sage.modules
1499
+ {0: 0, 1: 0, 2: 0, 3: 0}
1500
+ sage: R.is_cohen_macaulay() # needs sage.modules
1501
+ True
1502
+ """
1503
+ return UniqueSimplicialComplex(
1504
+ [[1, 9, 2, 5], [1, 10, 2, 5], [1, 10, 5, 11], [1, 10, 7, 11], [1, 13, 5, 11],
1505
+ [1, 13, 7, 11], [2, 10, 3, 6], [2, 11, 3, 6], [2, 11, 6, 12], [2, 11, 8, 12],
1506
+ [2, 14, 6, 12], [2, 14, 8, 12], [3, 11, 4, 7], [3, 12, 4, 7], [3, 12, 5, 9],
1507
+ [3, 12, 7, 9], [3, 13, 5, 9], [3, 13, 7, 9], [4, 9, 1, 8], [4, 9, 6, 10],
1508
+ [4, 9, 8, 10], [4, 12, 1, 8], [4, 14, 6, 10], [4, 14, 8, 10], [9, 10, 2, 5],
1509
+ [9, 10, 2, 6], [9, 10, 5, 11], [9, 10, 11, 12], [9, 13, 5, 11], [10, 11, 3, 6],
1510
+ [10, 11, 3, 7], [10, 11, 6, 12], [10, 14, 6, 12], [11, 12, 4, 7], [11, 12, 4, 8],
1511
+ [11, 12, 7, 9], [11, 13, 7, 9], [12, 9, 1, 5], [12, 9, 1, 8], [12, 9, 8, 10],
1512
+ [12, 14, 8, 10]],
1513
+ name="Rudin ball"
1514
+ )
1515
+
1516
+
1517
+ def ZieglerBall():
1518
+ r"""
1519
+ Return the non-shellable ball constructed by Ziegler.
1520
+
1521
+ This complex is a non-shellable triangulation of the 3-ball
1522
+ with 10 vertices and 21 facets, constructed by Ziegler in
1523
+ [Zie1998]_ and the smallest such complex known.
1524
+
1525
+ EXAMPLES::
1526
+
1527
+ sage: Z = simplicial_complexes.ZieglerBall(); Z
1528
+ Ziegler ball
1529
+ sage: Z.f_vector()
1530
+ [1, 10, 38, 50, 21]
1531
+ sage: Z.homology() # needs sage.modules
1532
+ {0: 0, 1: 0, 2: 0, 3: 0}
1533
+ sage: Z.is_cohen_macaulay() # needs sage.modules
1534
+ True
1535
+ """
1536
+
1537
+ return UniqueSimplicialComplex(
1538
+ [[1, 2, 3, 4], [1, 2, 5, 6], [1, 5, 6, 9], [2, 5, 6, 0], [3, 6, 7, 8], [4, 5, 7, 8],
1539
+ [2, 3, 6, 7], [1, 6, 2, 9], [2, 6, 7, 0], [3, 2, 4, 8], [4, 1, 3, 7], [3, 4, 7, 8],
1540
+ [1, 2, 4, 9], [2, 7, 3, 0], [3, 2, 6, 8], [4, 1, 5, 7], [4, 1, 8, 5], [1, 4, 8, 9],
1541
+ [2, 3, 1, 0], [1, 8, 5, 9], [2, 1, 5, 0]],
1542
+ name="Ziegler ball")
1543
+
1544
+
1545
+ def DunceHat():
1546
+ r"""
1547
+ Return the minimal triangulation of the dunce hat given by Hachimori
1548
+ [Hac2016]_.
1549
+
1550
+ This is a standard example of a space that is contractible
1551
+ but not collapsible.
1552
+
1553
+ EXAMPLES::
1554
+
1555
+ sage: D = simplicial_complexes.DunceHat(); D
1556
+ Minimal triangulation of the dunce hat
1557
+ sage: D.f_vector()
1558
+ [1, 8, 24, 17]
1559
+ sage: D.homology() # needs sage.modules
1560
+ {0: 0, 1: 0, 2: 0}
1561
+ sage: D.is_cohen_macaulay() # needs sage.modules
1562
+ True
1563
+ """
1564
+ return UniqueSimplicialComplex(
1565
+ [[1, 3, 5], [2, 3, 5], [2, 4, 5], [1, 2, 4], [1, 3, 4], [3, 4, 8],
1566
+ [1, 2, 8], [1, 7, 8], [1, 2, 7], [2, 3, 7], [3, 6, 7], [1, 3, 6],
1567
+ [1, 5, 6], [4, 5, 6], [4, 6, 8], [6, 7, 8], [2, 3, 8]],
1568
+ name="Minimal triangulation of the dunce hat")
1569
+
1570
+
1571
+ def FareyMap(p):
1572
+ r"""
1573
+ Return a discrete surface associated with `PSL(2, \GF(p))`.
1574
+
1575
+ INPUT:
1576
+
1577
+ - ``p`` -- a prime number
1578
+
1579
+ The vertices are the nonzero pairs `(x,y)` in `\GF(p)^2` modulo
1580
+ the identification of `(-x, -y)` with `(x,y)`.
1581
+
1582
+ The triangles are the images of the base triangle ((1,0),(0,1),(1,1))
1583
+ under the action of `PSL(2, \GF(p))`.
1584
+
1585
+ For `p = 3`, the result is a tetrahedron, for `p = 5` an icosahedron,
1586
+ and for `p = 7` a triangulation of the Klein quartic of genus `3`.
1587
+
1588
+ As a Riemann surface, this is the quotient of the upper half plane
1589
+ by the principal congruence subgroup `\Gamma(p)`.
1590
+
1591
+ EXAMPLES::
1592
+
1593
+ sage: S5 = simplicial_complexes.FareyMap(5); S5 # needs sage.groups
1594
+ Simplicial complex with 12 vertices and 20 facets
1595
+ sage: S5.automorphism_group().cardinality() # needs sage.groups
1596
+ 120
1597
+
1598
+ sage: S7 = simplicial_complexes.FareyMap(7); S7 # needs sage.groups
1599
+ Simplicial complex with 24 vertices and 56 facets
1600
+ sage: S7.f_vector() # needs sage.groups
1601
+ [1, 24, 84, 56]
1602
+
1603
+ REFERENCES:
1604
+
1605
+ - [ISS2019] Ioannis Ivrissimtzis, David Singerman and James Strudwick,
1606
+ *From Farey Fractions to the Klein Quartic and Beyond*.
1607
+ :arxiv:`1909.08568`
1608
+ """
1609
+ from sage.combinat.permutation import Permutation
1610
+ from sage.groups.perm_gps.permgroup import PermutationGroup
1611
+ from sage.matrix.constructor import matrix
1612
+ from sage.modules.free_module_element import vector
1613
+ from sage.rings.finite_rings.finite_field_constructor import GF
1614
+ from sage.libs.gap.libgap import libgap
1615
+
1616
+ def normalise(pair):
1617
+ x, y = pair
1618
+ if x != 0 and p - x < x:
1619
+ return ((-x) % p, (-y) % p)
1620
+ elif x == 0 and p - y < y:
1621
+ return (0, (-y) % p)
1622
+ return (x, y)
1623
+
1624
+ points = [(x, y) for x in range(p) for y in range(p)
1625
+ if (x, y) != (0, 0) and
1626
+ (x != 0 and p - x >= x or (x == 0 and p - y >= y))]
1627
+ convert = {pt: i + 1 for i, pt in enumerate(points)}
1628
+
1629
+ F = GF(p)
1630
+ S = matrix(F, 2, 2, [0, -1, 1, 0])
1631
+ T = matrix(F, 2, 2, [1, 1, 0, 1])
1632
+ perm_S = Permutation([convert[normalise(S * vector(pt))]
1633
+ for pt in points])
1634
+ perm_T = Permutation([convert[normalise(T * vector(pt))]
1635
+ for pt in points])
1636
+ group = PermutationGroup([perm_S, perm_T])
1637
+ triangle = [convert[normalise(pt)] for pt in [(1, 0), (0, 1), (1, 1)]]
1638
+ triangle = libgap.Set(triangle)
1639
+ triangles = libgap.Orbit(group, triangle, libgap.OnSets).sage()
1640
+ return SimplicialComplex(triangles)
1641
+
1642
+
1643
+ def GenusSix():
1644
+ """
1645
+ Return a triangulated surface of genus 6.
1646
+
1647
+ This is triangulated with 12 vertices, 66 edges and 44 faces. Each
1648
+ vertex is neighbour to all other vertices.
1649
+
1650
+ It appears as number `58` in the classification of Altshuler,
1651
+ Bokowski and Schuchert in [ABS96]_, where it is the unique surface
1652
+ with the largest symmetry group, of order 12. This article refers
1653
+ for this surface to Ringel.
1654
+
1655
+ EXAMPLES::
1656
+
1657
+ sage: S = simplicial_complexes.GenusSix()
1658
+ sage: S.automorphism_group().cardinality() # needs sage.groups
1659
+ 12
1660
+ sage: S.betti() # needs sage.modules
1661
+ {0: 1, 1: 12, 2: 1}
1662
+ sage: S.f_vector()
1663
+ [1, 12, 66, 44]
1664
+
1665
+ REFERENCES:
1666
+
1667
+ .. [ABS96] Amos Altshule, Jürgen Bokowski and Peter Schuchert,
1668
+ *Neighborly 2-Manifolds with 12 Vertices*,
1669
+ Journal of Combinatorial Theory, Series A, 75, 148-162 (1996),
1670
+ :doi:`10.1006/jcta.1996.0069`
1671
+ """
1672
+ L = ["014", "018", "023", "027", "036", "049",
1673
+ "056", "05b", "07a", "08a", "09b",
1674
+ "125", "126", "137", "139", "147", "15a",
1675
+ "16b", "18b", "19a", "23b", "248",
1676
+ "24a", "258", "269", "279", "2ab", "345",
1677
+ "34b", "35a", "367", "389", "38a",
1678
+ "459", "46a", "46b", "478", "568", "579",
1679
+ "57b", "67a", "689", "78b", "9ab"]
1680
+ return SimplicialComplex([list(w) for w in L])