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,538 @@
1
+ # sage_setup: distribution = sagemath-graphs
2
+ r"""
3
+ Chessboard graphs
4
+
5
+ The methods defined here appear in :mod:`sage.graphs.graph_generators`.
6
+
7
+ - :meth:`BishopGraph <sage.graphs.graph_generators.GraphGenerators.BishopGraph>`
8
+ - :meth:`KingGraph <sage.graphs.graph_generators.GraphGenerators.KingGraph>`
9
+ - :meth:`KnightGraph <sage.graphs.graph_generators.GraphGenerators.KnightGraph>`
10
+ - :meth:`QueenGraph <sage.graphs.graph_generators.GraphGenerators.QueenGraph>`
11
+ - :meth:`RookGraph <sage.graphs.graph_generators.GraphGenerators.RookGraph>`
12
+
13
+ AUTHORS:
14
+
15
+ - David Coudert (2012)
16
+ """
17
+
18
+ # ****************************************************************************
19
+ # Copyright (C) 2012 David Coudert <david.coudert@inria.fr>
20
+ #
21
+ # Distributed under the terms of the GNU General Public License (GPL)
22
+ # http://www.gnu.org/licenses/
23
+ # ****************************************************************************
24
+
25
+ from itertools import product
26
+ from itertools import combinations
27
+ from sage.graphs.graph import Graph
28
+
29
+
30
+ def ChessboardGraphGenerator(dim_list, rook=True, rook_radius=None,
31
+ bishop=True, bishop_radius=None,
32
+ knight=True, knight_x=1, knight_y=2,
33
+ relabel=False):
34
+ r"""
35
+ Return a Graph built on a `d`-dimensional chessboard with prescribed
36
+ dimensions and interconnections.
37
+
38
+ This function allows to generate many kinds of graphs corresponding to legal
39
+ movements on a `d`-dimensional chessboard: Queen Graph, King Graph, Knight
40
+ Graphs, Bishop Graph, and many generalizations. It also allows to avoid
41
+ redundant code.
42
+
43
+ INPUT:
44
+
45
+ - ``dim_list`` -- iterable (list, set, dict); provides the dimensions
46
+ `n_1, n_2, \ldots, n_d`, with `n_i \geq 1`, of the chessboard
47
+
48
+ - ``rook`` -- boolean (default: ``True``); indicates whether the chess piece
49
+ is able to move as a rook, that is at any distance along a dimension
50
+
51
+ - ``rook_radius`` -- integer (default: ``None``); restriction on the
52
+ rook-like movements to distance at most ``rook_radius``
53
+
54
+ - ``bishop`` -- boolean (default: ``True``); indicates whether the chess
55
+ piece is able to move like a bishop, that is along diagonals
56
+
57
+ - ``bishop_radius`` -- integer (default: ``None``); restriction on the
58
+ bishop-like movements to distance at most ``bishop_radius``
59
+
60
+ - ``knight`` -- boolean (default: ``True``); indicating whether the chess
61
+ piece is able to move like a knight
62
+
63
+ - ``knight_x`` -- integer (default: `1`); indicates the number on steps
64
+ the chess piece moves in one dimension when moving like a knight
65
+
66
+ - ``knight_y`` -- integer (default: `2`); indicates the number on steps
67
+ the chess piece moves in the second dimension when moving like a knight
68
+
69
+ - ``relabel`` -- boolean (default: ``False``); indicates whether the
70
+ vertices must be relabeled as integers
71
+
72
+ OUTPUT:
73
+
74
+ - A Graph build on a `d`-dimensional chessboard with prescribed dimensions,
75
+ and with edges according given parameters.
76
+
77
+ - A string encoding the dimensions. This is mainly useful for providing
78
+ names to graphs.
79
+
80
+ EXAMPLES:
81
+
82
+ A `(2,2)`-King Graph is isomorphic to the complete graph on 4 vertices::
83
+
84
+ sage: G, _ = graphs.ChessboardGraphGenerator( [2,2] )
85
+ sage: G.is_isomorphic( graphs.CompleteGraph(4) )
86
+ True
87
+
88
+ A Rook's Graph in 2 dimensions is isomorphic to the Cartesian product of 2
89
+ complete graphs::
90
+
91
+ sage: G, _ = graphs.ChessboardGraphGenerator([3,4], rook=True, rook_radius=None, bishop=False, knight=False)
92
+ sage: H = (graphs.CompleteGraph(3)).cartesian_product(graphs.CompleteGraph(4))
93
+ sage: G.is_isomorphic(H)
94
+ True
95
+
96
+ TESTS:
97
+
98
+ Giving dimensions less than 2::
99
+
100
+ sage: graphs.ChessboardGraphGenerator([0, 2])
101
+ Traceback (most recent call last):
102
+ ...
103
+ ValueError: the dimensions must be positive integers larger than 1
104
+
105
+ Giving non integer dimensions::
106
+
107
+ sage: graphs.ChessboardGraphGenerator([4.5, 2])
108
+ Traceback (most recent call last):
109
+ ...
110
+ ValueError: the dimensions must be positive integers larger than 1
111
+
112
+ Giving too few dimensions::
113
+
114
+ sage: graphs.ChessboardGraphGenerator([2])
115
+ Traceback (most recent call last):
116
+ ...
117
+ ValueError: the chessboard must have at least 2 dimensions
118
+
119
+ Giving a non-iterable object as first parameter::
120
+
121
+ sage: graphs.ChessboardGraphGenerator(2, 3)
122
+ Traceback (most recent call last):
123
+ ...
124
+ TypeError: the first parameter must be an iterable object
125
+
126
+ Giving too small rook radius::
127
+
128
+ sage: graphs.ChessboardGraphGenerator([2, 3], rook=True, rook_radius=0)
129
+ Traceback (most recent call last):
130
+ ...
131
+ ValueError: the rook_radius must be either None or have an integer value >= 1
132
+
133
+ Giving wrong values for knights movements::
134
+
135
+ sage: graphs.ChessboardGraphGenerator([2, 3], rook=False, bishop=False, knight=True, knight_x=1, knight_y=-1)
136
+ Traceback (most recent call last):
137
+ ...
138
+ ValueError: the knight_x and knight_y values must be integers of value >= 1
139
+ """
140
+ from sage.rings.integer_ring import ZZ
141
+
142
+ # We decode the dimensions of the chessboard
143
+ try:
144
+ dim = list(dim_list)
145
+ nb_dim = len(dim)
146
+ except TypeError:
147
+ raise TypeError('the first parameter must be an iterable object')
148
+ if nb_dim < 2:
149
+ raise ValueError('the chessboard must have at least 2 dimensions')
150
+ if any(a not in ZZ or a < 1 for a in dim):
151
+ raise ValueError('the dimensions must be positive integers larger than 1')
152
+ dimstr = str(tuple(dim))
153
+
154
+ # We check the radius toward neighbors
155
+ if rook:
156
+ if rook_radius is None:
157
+ rook_radius = max(dim)
158
+ elif rook_radius not in ZZ or rook_radius < 1:
159
+ raise ValueError('the rook_radius must be either None or have an integer value >= 1')
160
+ if bishop:
161
+ if bishop_radius is None:
162
+ bishop_radius = max(dim)
163
+ elif bishop_radius not in ZZ or bishop_radius < 1:
164
+ raise ValueError('the bishop_radius must be either None or have an integer value >= 1')
165
+ if knight and (knight_x not in ZZ or knight_y not in ZZ or knight_x < 1 or knight_y < 1):
166
+ raise ValueError('the knight_x and knight_y values must be integers of value >= 1')
167
+
168
+ # We build the set of vertices of the d-dimensional chessboard
169
+ V = [list(x) for x in list(product(*[range(_) for _ in dim]))]
170
+
171
+ G = Graph()
172
+ for u in V:
173
+ uu = tuple(u)
174
+ G.add_vertex(uu)
175
+
176
+ if rook:
177
+ # We add edges to vertices we can reach when moving in one dimension
178
+ for d in range(nb_dim):
179
+ v = u[:]
180
+ for k in range(v[d] + 1, min(dim[d], v[d] + 1 + rook_radius)):
181
+ v[d] = k
182
+ G.add_edge(uu, tuple(v))
183
+
184
+ if bishop or knight:
185
+ # We add edges to vertices we can reach when moving in two dimensions
186
+ for dx, dy in combinations(range(nb_dim), 2):
187
+ n = dim[dx]
188
+ m = dim[dy]
189
+ v = u[:]
190
+ i = u[dx]
191
+ j = u[dy]
192
+
193
+ if bishop:
194
+ # Diagonal
195
+ for k in range(1, min(n - i, m - j, bishop_radius + 1)):
196
+ v[dx] = i + k
197
+ v[dy] = j + k
198
+ G.add_edge(uu, tuple(v))
199
+
200
+ # Anti-diagonal
201
+ for k in range(min(i, m - j - 1, bishop_radius)):
202
+ v[dx] = i - k - 1
203
+ v[dy] = j + k + 1
204
+ G.add_edge(uu, tuple(v))
205
+
206
+ if knight:
207
+ # Moving knight_x in one dimension and knight_y in another
208
+ # dimension
209
+ if i + knight_y < n:
210
+ if j + knight_x < m:
211
+ v[dx] = i + knight_y
212
+ v[dy] = j + knight_x
213
+ G.add_edge(uu, tuple(v))
214
+ if j - knight_x >= 0:
215
+ v[dx] = i + knight_y
216
+ v[dy] = j - knight_x
217
+ G.add_edge(uu, tuple(v))
218
+ if j + knight_y < m:
219
+ if i + knight_x < n:
220
+ v[dx] = i + knight_x
221
+ v[dy] = j + knight_y
222
+ G.add_edge(uu, tuple(v))
223
+ if i - knight_x >= 0:
224
+ v[dx] = i - knight_x
225
+ v[dy] = j + knight_y
226
+ G.add_edge(uu, tuple(v))
227
+
228
+ if relabel:
229
+ G.relabel(inplace=True)
230
+ return G, dimstr
231
+
232
+
233
+ def QueenGraph(dim_list, radius=None, relabel=False):
234
+ r"""
235
+ Return the `d`-dimensional Queen Graph with prescribed dimensions.
236
+
237
+ The 2-dimensional Queen Graph of parameters `n` and `m` is a graph with `nm`
238
+ vertices in which each vertex represents a square in an `n \times m`
239
+ chessboard, and each edge corresponds to a legal move by a queen.
240
+
241
+ The `d`-dimensional Queen Graph with `d >= 2` has for vertex set the cells
242
+ of a `d`-dimensional grid with prescribed dimensions, and each edge
243
+ corresponds to a legal move by a queen in either one or two dimensions.
244
+
245
+ All 2-dimensional Queen Graphs are Hamiltonian and biconnected. The
246
+ chromatic number of a `(n,n)`-Queen Graph is at least `n`, and it is exactly
247
+ `n` when `n\equiv 1,5 \bmod{6}`.
248
+
249
+ INPUT:
250
+
251
+ - ``dim_list`` -- iterable (list, set, dict); provides the dimensions
252
+ `n_1, n_2, \ldots, n_d`, with `n_i \geq 1`, of the chessboard
253
+
254
+ - ``radius`` -- integer (default: ``None``); by setting the radius to a
255
+ positive integer, one may reduce the visibility of the queen to at most
256
+ ``radius`` steps. When radius is 1, the resulting graph is a King Graph.
257
+
258
+ - ``relabel`` -- boolean (default: ``False``); indicates whether the
259
+ vertices must be relabeled as integers
260
+
261
+ EXAMPLES:
262
+
263
+ The `(2,2)`-Queen Graph is isomorphic to the complete graph on 4 vertices::
264
+
265
+ sage: G = graphs.QueenGraph([2, 2])
266
+ sage: G.is_isomorphic(graphs.CompleteGraph(4))
267
+ True
268
+
269
+ The Queen Graph with radius 1 is isomorphic to the King Graph::
270
+
271
+ sage: G = graphs.QueenGraph([4, 5], radius=1)
272
+ sage: H = graphs.KingGraph([5, 4])
273
+ sage: G.is_isomorphic(H)
274
+ True
275
+
276
+ Also ``True`` in higher dimensions::
277
+
278
+ sage: G = graphs.QueenGraph([3, 4, 5], radius=1)
279
+ sage: H = graphs.KingGraph([5, 3, 4])
280
+ sage: G.is_isomorphic(H)
281
+ True
282
+
283
+ The Queen Graph can be obtained from the Rook Graph and the Bishop Graph::
284
+
285
+ sage: for d in range(3,12): # long time
286
+ ....: for r in range(1,d+1):
287
+ ....: G = graphs.QueenGraph([d,d],radius=r)
288
+ ....: H = graphs.RookGraph([d,d],radius=r)
289
+ ....: B = graphs.BishopGraph([d,d],radius=r)
290
+ ....: H.add_edges(B.edges(sort=False))
291
+ ....: if not G.is_isomorphic(H):
292
+ ....: print("that's not good!")
293
+ """
294
+ G, dimstr = ChessboardGraphGenerator(dim_list,
295
+ rook=True, rook_radius=radius,
296
+ bishop=True, bishop_radius=radius,
297
+ knight=False,
298
+ relabel=relabel)
299
+ if radius is None:
300
+ G.name(dimstr + "-Queen Graph")
301
+ else:
302
+ G.name(dimstr + "-Queen Graph with radius {}".format(radius))
303
+ return G
304
+
305
+
306
+ def KingGraph(dim_list, radius=None, relabel=False):
307
+ r"""
308
+ Return the `d`-dimensional King Graph with prescribed dimensions.
309
+
310
+ The 2-dimensional King Graph of parameters `n` and `m` is a graph with `nm`
311
+ vertices in which each vertex represents a square in an `n \times m`
312
+ chessboard, and each edge corresponds to a legal move by a king.
313
+
314
+ The d-dimensional King Graph with `d >= 2` has for vertex set the cells of a
315
+ d-dimensional grid with prescribed dimensions, and each edge corresponds to
316
+ a legal move by a king in either one or two dimensions.
317
+
318
+ All 2-dimensional King Graphs are Hamiltonian, biconnected, and have
319
+ chromatic number 4 as soon as both dimensions are larger or equal to 2.
320
+
321
+ INPUT:
322
+
323
+ - ``dim_list`` -- iterable (list, set, dict); provides the dimensions
324
+ `n_1, n_2, \ldots, n_d`, with `n_i \geq 1`, of the chessboard
325
+
326
+ - ``radius`` -- integer (default: ``None``); by setting the radius to a
327
+ positive integer, one may increase the power of the king to at least
328
+ ``radius`` steps. When the radius equals the higher size of the
329
+ dimensions, the resulting graph is a Queen Graph.
330
+
331
+ - ``relabel`` -- boolean (default: ``False``); indicates whether the
332
+ vertices must be relabeled as integers
333
+
334
+ EXAMPLES:
335
+
336
+ The `(2,2)`-King Graph is isomorphic to the complete graph on 4 vertices::
337
+
338
+ sage: G = graphs.QueenGraph( [2, 2] )
339
+ sage: G.is_isomorphic( graphs.CompleteGraph(4) )
340
+ True
341
+
342
+ The King Graph with large enough radius is isomorphic to a Queen Graph::
343
+
344
+ sage: G = graphs.KingGraph( [5, 4], radius=5 )
345
+ sage: H = graphs.QueenGraph( [4, 5] )
346
+ sage: G.is_isomorphic( H )
347
+ True
348
+
349
+ Also ``True`` in higher dimensions::
350
+
351
+ sage: G = graphs.KingGraph( [2, 5, 4], radius=5 )
352
+ sage: H = graphs.QueenGraph( [4, 5, 2] )
353
+ sage: G.is_isomorphic( H )
354
+ True
355
+ """
356
+ rook_radius = 1 if radius is None else radius
357
+ bishop_radius = 1 if radius is None else radius
358
+ G, dimstr = ChessboardGraphGenerator(dim_list,
359
+ rook=True, rook_radius=rook_radius,
360
+ bishop=True, bishop_radius=bishop_radius,
361
+ knight=False,
362
+ relabel=relabel)
363
+ if radius is None:
364
+ G.name(dimstr + "-King Graph")
365
+ else:
366
+ G.name(dimstr + "-King Graph with radius {}".format(radius))
367
+ return G
368
+
369
+
370
+ def KnightGraph(dim_list, one=1, two=2, relabel=False):
371
+ r"""
372
+ Return the d-dimensional Knight Graph with prescribed dimensions.
373
+
374
+ The 2-dimensional Knight Graph of parameters `n` and `m` is a graph with
375
+ `nm` vertices in which each vertex represents a square in an `n \times m`
376
+ chessboard, and each edge corresponds to a legal move by a knight.
377
+
378
+ The d-dimensional Knight Graph with `d >= 2` has for vertex set the cells of
379
+ a d-dimensional grid with prescribed dimensions, and each edge corresponds
380
+ to a legal move by a knight in any pairs of dimensions.
381
+
382
+ The `(n,n)`-Knight Graph is Hamiltonian for even `n > 4`.
383
+
384
+ INPUT:
385
+
386
+ - ``dim_list`` -- iterable (list, set, dict); provides the dimensions
387
+ `n_1, n_2, \ldots, n_d`, with `n_i \geq 1`, of the chessboard
388
+
389
+ - ``one`` -- integer (default: `1`); indicates the number of steps in the
390
+ first dimension
391
+
392
+ - ``two`` -- integer (default: `2`); indicates the number of steps in the
393
+ second dimension
394
+
395
+ - ``relabel`` -- boolean (default: ``False``); indicates whether the
396
+ vertices must be relabeled as integers
397
+
398
+ EXAMPLES:
399
+
400
+ The `(3,3)`-Knight Graph has an isolated vertex::
401
+
402
+ sage: G = graphs.KnightGraph( [3, 3] )
403
+ sage: G.degree( (1,1) )
404
+ 0
405
+
406
+ The `(3,3)`-Knight Graph minus vertex (1,1) is a cycle of order 8::
407
+
408
+ sage: G = graphs.KnightGraph( [3, 3] )
409
+ sage: G.delete_vertex( (1,1) )
410
+ sage: G.is_isomorphic( graphs.CycleGraph(8) )
411
+ True
412
+
413
+ The `(6,6)`-Knight Graph is Hamiltonian::
414
+
415
+ sage: G = graphs.KnightGraph( [6, 6] )
416
+ sage: G.is_hamiltonian() # needs sage.numerical.mip
417
+ True
418
+ """
419
+ G, dimstr = ChessboardGraphGenerator(dim_list,
420
+ rook=False, bishop=False,
421
+ knight=True, knight_x=one, knight_y=two,
422
+ relabel=relabel)
423
+ if one + two == 3:
424
+ G.name(dimstr + "-Knight Graph")
425
+ else:
426
+ G.name(dimstr + "-Knight Graph with edges at distance ({}, {})".format(one, two))
427
+ return G
428
+
429
+
430
+ def RookGraph(dim_list, radius=None, relabel=False):
431
+ r"""
432
+ Return the `d`-dimensional Rook's Graph with prescribed dimensions.
433
+
434
+ The 2-dimensional Rook's Graph of parameters `n` and `m` is a graph with
435
+ `nm` vertices in which each vertex represents a square in an `n \times m`
436
+ chessboard, and each edge corresponds to a legal move by a rook.
437
+
438
+ The `d`-dimensional Rook Graph with `d >= 2` has for vertex set the cells of
439
+ a `d`-dimensional grid with prescribed dimensions, and each edge corresponds
440
+ to a legal move by a rook in any of the dimensions.
441
+
442
+ The Rook's Graph for an `n\times m` chessboard may also be defined as the
443
+ Cartesian product of two complete graphs `K_n \square K_m`.
444
+
445
+ INPUT:
446
+
447
+ - ``dim_list`` -- iterable (list, set, dict); provides the dimensions
448
+ `n_1, n_2, \ldots, n_d`, with `n_i \geq 1`, of the chessboard
449
+
450
+ - ``radius`` -- integer (default: ``None``); by setting the radius to a
451
+ positive integer, one may decrease the power of the rook to at most
452
+ ``radius`` steps. When the radius is 1, the resulting graph is a
453
+ `d`-dimensional grid.
454
+
455
+ - ``relabel`` -- boolean (default: ``False``); indicates whether the
456
+ vertices must be relabeled as integers
457
+
458
+ EXAMPLES:
459
+
460
+ The `(n,m)`-Rook's Graph is isomorphic to the Cartesian product of two
461
+ complete graphs::
462
+
463
+ sage: G = graphs.RookGraph( [3, 4] )
464
+ sage: H = ( graphs.CompleteGraph(3) ).cartesian_product( graphs.CompleteGraph(4) )
465
+ sage: G.is_isomorphic( H )
466
+ True
467
+
468
+ When the radius is 1, the Rook's Graph is a grid::
469
+
470
+ sage: G = graphs.RookGraph( [3, 3, 4], radius=1 )
471
+ sage: H = graphs.GridGraph( [3, 4, 3] )
472
+ sage: G.is_isomorphic( H )
473
+ True
474
+ """
475
+ G, dimstr = ChessboardGraphGenerator(dim_list,
476
+ rook=True, rook_radius=radius,
477
+ bishop=False, knight=False,
478
+ relabel=relabel)
479
+ if radius is None:
480
+ G.name(dimstr + "-Rook Graph")
481
+ else:
482
+ G.name(dimstr + "-Rook Graph with radius {}".format(radius))
483
+ return G
484
+
485
+
486
+ def BishopGraph(dim_list, radius=None, relabel=False):
487
+ r"""
488
+ Return the `d`-dimensional Bishop Graph with prescribed dimensions.
489
+
490
+ The 2-dimensional Bishop Graph of parameters `n` and `m` is a graph with
491
+ `nm` vertices in which each vertex represents a square in an `n \times m`
492
+ chessboard, and each edge corresponds to a legal move by a bishop.
493
+
494
+ The `d`-dimensional Bishop Graph with `d >= 2` has for vertex set the cells
495
+ of a `d`-dimensional grid with prescribed dimensions, and each edge
496
+ corresponds to a legal move by a bishop in any pairs of dimensions.
497
+
498
+ The Bishop Graph is not connected.
499
+
500
+ INPUT:
501
+
502
+ - ``dim_list`` -- iterable (list, set, dict); provides the dimensions
503
+ `n_1, n_2, \ldots, n_d`, with `n_i \geq 1`, of the chessboard
504
+
505
+ - ``radius`` -- integer (default: ``None``); by setting the radius to a
506
+ positive integer, one may decrease the power of the bishop to at most
507
+ ``radius`` steps.
508
+
509
+ - ``relabel`` -- boolean (default: ``False``); indicates whether the
510
+ vertices must be relabeled as integers
511
+
512
+ EXAMPLES:
513
+
514
+ The (n,m)-Bishop Graph is not connected::
515
+
516
+ sage: G = graphs.BishopGraph( [3, 4] )
517
+ sage: G.is_connected()
518
+ False
519
+
520
+ The Bishop Graph can be obtained from Knight Graphs::
521
+
522
+ sage: for d in range(3,12): # long time
523
+ ....: H = Graph()
524
+ ....: for r in range(1,d+1):
525
+ ....: B = graphs.BishopGraph([d,d],radius=r)
526
+ ....: H.add_edges( graphs.KnightGraph([d,d],one=r,two=r).edges(sort=False) )
527
+ ....: if not B.is_isomorphic(H):
528
+ ....: print("that's not good!")
529
+ """
530
+ G, dimstr = ChessboardGraphGenerator(dim_list,
531
+ rook=False, knight=False,
532
+ bishop=True, bishop_radius=radius,
533
+ relabel=relabel)
534
+ if radius is None:
535
+ G.name(dimstr + "-Bishop Graph")
536
+ else:
537
+ G.name(dimstr + "-Bishop Graph with radius {}".format(radius))
538
+ return G