passagemath-graphs 10.5.43__cp39-cp39-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 (258) hide show
  1. passagemath_graphs-10.5.43.dist-info/METADATA +293 -0
  2. passagemath_graphs-10.5.43.dist-info/RECORD +258 -0
  3. passagemath_graphs-10.5.43.dist-info/WHEEL +5 -0
  4. passagemath_graphs-10.5.43.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 +2552 -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 +125 -0
  15. sage/combinat/cluster_algebra_quiver/mutation_class.py +625 -0
  16. sage/combinat/cluster_algebra_quiver/mutation_type.py +1556 -0
  17. sage/combinat/cluster_algebra_quiver/quiver.py +2262 -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 +534 -0
  25. sage/combinat/designs/database.py +5614 -0
  26. sage/combinat/designs/design_catalog.py +122 -0
  27. sage/combinat/designs/designs_pyx.cpython-39-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-39-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-39-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 +548 -0
  40. sage/combinat/designs/orthogonal_arrays.py +2243 -0
  41. sage/combinat/designs/orthogonal_arrays_build_recursive.py +1780 -0
  42. sage/combinat/designs/orthogonal_arrays_find_recursive.cpython-39-aarch64-linux-gnu.so +0 -0
  43. sage/combinat/designs/orthogonal_arrays_find_recursive.pyx +966 -0
  44. sage/combinat/designs/resolvable_bibd.py +781 -0
  45. sage/combinat/designs/steiner_quadruple_systems.py +1306 -0
  46. sage/combinat/designs/subhypergraph_search.cpython-39-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/cartesian_product.py +493 -0
  57. sage/combinat/posets/d_complete.py +182 -0
  58. sage/combinat/posets/elements.py +273 -0
  59. sage/combinat/posets/forest.py +30 -0
  60. sage/combinat/posets/hasse_cython.cpython-39-aarch64-linux-gnu.so +0 -0
  61. sage/combinat/posets/hasse_cython.pyx +174 -0
  62. sage/combinat/posets/hasse_diagram.py +3678 -0
  63. sage/combinat/posets/incidence_algebras.py +796 -0
  64. sage/combinat/posets/lattices.py +5119 -0
  65. sage/combinat/posets/linear_extension_iterator.cpython-39-aarch64-linux-gnu.so +0 -0
  66. sage/combinat/posets/linear_extension_iterator.pyx +292 -0
  67. sage/combinat/posets/linear_extensions.py +1039 -0
  68. sage/combinat/posets/mobile.py +275 -0
  69. sage/combinat/posets/moebius_algebra.py +776 -0
  70. sage/combinat/posets/poset_examples.py +2131 -0
  71. sage/combinat/posets/posets.py +9169 -0
  72. sage/combinat/rooted_tree.py +1070 -0
  73. sage/combinat/shard_order.py +239 -0
  74. sage/combinat/tamari_lattices.py +384 -0
  75. sage/combinat/yang_baxter_graph.py +923 -0
  76. sage/databases/all__sagemath_graphs.py +1 -0
  77. sage/databases/knotinfo_db.py +1230 -0
  78. sage/ext_data/all__sagemath_graphs.py +1 -0
  79. sage/ext_data/graphs/graph_plot_js.html +330 -0
  80. sage/ext_data/kenzo/CP2.txt +45 -0
  81. sage/ext_data/kenzo/CP3.txt +349 -0
  82. sage/ext_data/kenzo/CP4.txt +4774 -0
  83. sage/ext_data/kenzo/README.txt +49 -0
  84. sage/ext_data/kenzo/S4.txt +20 -0
  85. sage/graphs/all.py +42 -0
  86. sage/graphs/asteroidal_triples.cpython-39-aarch64-linux-gnu.so +0 -0
  87. sage/graphs/asteroidal_triples.pyx +299 -0
  88. sage/graphs/base/all.py +1 -0
  89. sage/graphs/base/boost_graph.cpython-39-aarch64-linux-gnu.so +0 -0
  90. sage/graphs/base/boost_graph.pxd +106 -0
  91. sage/graphs/base/boost_graph.pyx +3045 -0
  92. sage/graphs/base/c_graph.cpython-39-aarch64-linux-gnu.so +0 -0
  93. sage/graphs/base/c_graph.pxd +106 -0
  94. sage/graphs/base/c_graph.pyx +5096 -0
  95. sage/graphs/base/dense_graph.cpython-39-aarch64-linux-gnu.so +0 -0
  96. sage/graphs/base/dense_graph.pxd +26 -0
  97. sage/graphs/base/dense_graph.pyx +757 -0
  98. sage/graphs/base/graph_backends.cpython-39-aarch64-linux-gnu.so +0 -0
  99. sage/graphs/base/graph_backends.pxd +5 -0
  100. sage/graphs/base/graph_backends.pyx +797 -0
  101. sage/graphs/base/overview.py +85 -0
  102. sage/graphs/base/sparse_graph.cpython-39-aarch64-linux-gnu.so +0 -0
  103. sage/graphs/base/sparse_graph.pxd +90 -0
  104. sage/graphs/base/sparse_graph.pyx +1653 -0
  105. sage/graphs/base/static_dense_graph.cpython-39-aarch64-linux-gnu.so +0 -0
  106. sage/graphs/base/static_dense_graph.pxd +5 -0
  107. sage/graphs/base/static_dense_graph.pyx +1032 -0
  108. sage/graphs/base/static_sparse_backend.cpython-39-aarch64-linux-gnu.so +0 -0
  109. sage/graphs/base/static_sparse_backend.pxd +27 -0
  110. sage/graphs/base/static_sparse_backend.pyx +1580 -0
  111. sage/graphs/base/static_sparse_graph.cpython-39-aarch64-linux-gnu.so +0 -0
  112. sage/graphs/base/static_sparse_graph.pxd +37 -0
  113. sage/graphs/base/static_sparse_graph.pyx +1304 -0
  114. sage/graphs/bipartite_graph.py +2709 -0
  115. sage/graphs/centrality.cpython-39-aarch64-linux-gnu.so +0 -0
  116. sage/graphs/centrality.pyx +965 -0
  117. sage/graphs/cographs.py +519 -0
  118. sage/graphs/comparability.cpython-39-aarch64-linux-gnu.so +0 -0
  119. sage/graphs/comparability.pyx +813 -0
  120. sage/graphs/connectivity.cpython-39-aarch64-linux-gnu.so +0 -0
  121. sage/graphs/connectivity.pxd +157 -0
  122. sage/graphs/connectivity.pyx +4813 -0
  123. sage/graphs/convexity_properties.cpython-39-aarch64-linux-gnu.so +0 -0
  124. sage/graphs/convexity_properties.pxd +16 -0
  125. sage/graphs/convexity_properties.pyx +827 -0
  126. sage/graphs/digraph.py +4410 -0
  127. sage/graphs/digraph_generators.py +1921 -0
  128. sage/graphs/distances_all_pairs.cpython-39-aarch64-linux-gnu.so +0 -0
  129. sage/graphs/distances_all_pairs.pxd +12 -0
  130. sage/graphs/distances_all_pairs.pyx +2938 -0
  131. sage/graphs/domination.py +1363 -0
  132. sage/graphs/dot2tex_utils.py +100 -0
  133. sage/graphs/edge_connectivity.cpython-39-aarch64-linux-gnu.so +0 -0
  134. sage/graphs/edge_connectivity.pyx +1215 -0
  135. sage/graphs/generators/all.py +1 -0
  136. sage/graphs/generators/basic.py +1769 -0
  137. sage/graphs/generators/chessboard.py +538 -0
  138. sage/graphs/generators/classical_geometries.py +1611 -0
  139. sage/graphs/generators/degree_sequence.py +235 -0
  140. sage/graphs/generators/distance_regular.cpython-39-aarch64-linux-gnu.so +0 -0
  141. sage/graphs/generators/distance_regular.pyx +2846 -0
  142. sage/graphs/generators/families.py +4749 -0
  143. sage/graphs/generators/intersection.py +565 -0
  144. sage/graphs/generators/platonic_solids.py +262 -0
  145. sage/graphs/generators/random.py +2623 -0
  146. sage/graphs/generators/smallgraphs.py +5741 -0
  147. sage/graphs/generators/world_map.py +724 -0
  148. sage/graphs/generic_graph.py +26395 -0
  149. sage/graphs/generic_graph_pyx.cpython-39-aarch64-linux-gnu.so +0 -0
  150. sage/graphs/generic_graph_pyx.pxd +34 -0
  151. sage/graphs/generic_graph_pyx.pyx +1626 -0
  152. sage/graphs/genus.cpython-39-aarch64-linux-gnu.so +0 -0
  153. sage/graphs/genus.pyx +623 -0
  154. sage/graphs/graph.py +9362 -0
  155. sage/graphs/graph_coloring.cpython-39-aarch64-linux-gnu.so +0 -0
  156. sage/graphs/graph_coloring.pyx +2284 -0
  157. sage/graphs/graph_database.py +1122 -0
  158. sage/graphs/graph_decompositions/all.py +1 -0
  159. sage/graphs/graph_decompositions/bandwidth.cpython-39-aarch64-linux-gnu.so +0 -0
  160. sage/graphs/graph_decompositions/bandwidth.pyx +428 -0
  161. sage/graphs/graph_decompositions/clique_separators.cpython-39-aarch64-linux-gnu.so +0 -0
  162. sage/graphs/graph_decompositions/clique_separators.pyx +595 -0
  163. sage/graphs/graph_decompositions/cutwidth.cpython-39-aarch64-linux-gnu.so +0 -0
  164. sage/graphs/graph_decompositions/cutwidth.pyx +753 -0
  165. sage/graphs/graph_decompositions/fast_digraph.cpython-39-aarch64-linux-gnu.so +0 -0
  166. sage/graphs/graph_decompositions/fast_digraph.pxd +13 -0
  167. sage/graphs/graph_decompositions/fast_digraph.pyx +212 -0
  168. sage/graphs/graph_decompositions/graph_products.cpython-39-aarch64-linux-gnu.so +0 -0
  169. sage/graphs/graph_decompositions/graph_products.pyx +462 -0
  170. sage/graphs/graph_decompositions/modular_decomposition.cpython-39-aarch64-linux-gnu.so +0 -0
  171. sage/graphs/graph_decompositions/modular_decomposition.pxd +27 -0
  172. sage/graphs/graph_decompositions/modular_decomposition.pyx +1536 -0
  173. sage/graphs/graph_decompositions/slice_decomposition.cpython-39-aarch64-linux-gnu.so +0 -0
  174. sage/graphs/graph_decompositions/slice_decomposition.pxd +18 -0
  175. sage/graphs/graph_decompositions/slice_decomposition.pyx +1080 -0
  176. sage/graphs/graph_decompositions/tree_decomposition.cpython-39-aarch64-linux-gnu.so +0 -0
  177. sage/graphs/graph_decompositions/tree_decomposition.pxd +17 -0
  178. sage/graphs/graph_decompositions/tree_decomposition.pyx +1996 -0
  179. sage/graphs/graph_decompositions/vertex_separation.cpython-39-aarch64-linux-gnu.so +0 -0
  180. sage/graphs/graph_decompositions/vertex_separation.pxd +5 -0
  181. sage/graphs/graph_decompositions/vertex_separation.pyx +1963 -0
  182. sage/graphs/graph_editor.py +82 -0
  183. sage/graphs/graph_generators.py +3301 -0
  184. sage/graphs/graph_generators_pyx.cpython-39-aarch64-linux-gnu.so +0 -0
  185. sage/graphs/graph_generators_pyx.pyx +95 -0
  186. sage/graphs/graph_input.py +812 -0
  187. sage/graphs/graph_latex.py +2064 -0
  188. sage/graphs/graph_list.py +367 -0
  189. sage/graphs/graph_plot.py +1749 -0
  190. sage/graphs/graph_plot_js.py +338 -0
  191. sage/graphs/hyperbolicity.cpython-39-aarch64-linux-gnu.so +0 -0
  192. sage/graphs/hyperbolicity.pyx +1702 -0
  193. sage/graphs/hypergraph_generators.py +364 -0
  194. sage/graphs/independent_sets.cpython-39-aarch64-linux-gnu.so +0 -0
  195. sage/graphs/independent_sets.pxd +13 -0
  196. sage/graphs/independent_sets.pyx +402 -0
  197. sage/graphs/isgci.py +1033 -0
  198. sage/graphs/isoperimetric_inequalities.cpython-39-aarch64-linux-gnu.so +0 -0
  199. sage/graphs/isoperimetric_inequalities.pyx +453 -0
  200. sage/graphs/line_graph.cpython-39-aarch64-linux-gnu.so +0 -0
  201. sage/graphs/line_graph.pyx +627 -0
  202. sage/graphs/lovasz_theta.py +77 -0
  203. sage/graphs/matching.py +1633 -0
  204. sage/graphs/matching_covered_graph.py +3566 -0
  205. sage/graphs/orientations.py +1504 -0
  206. sage/graphs/partial_cube.py +459 -0
  207. sage/graphs/path_enumeration.cpython-39-aarch64-linux-gnu.so +0 -0
  208. sage/graphs/path_enumeration.pyx +2040 -0
  209. sage/graphs/pq_trees.py +1129 -0
  210. sage/graphs/print_graphs.py +201 -0
  211. sage/graphs/schnyder.py +865 -0
  212. sage/graphs/spanning_tree.cpython-39-aarch64-linux-gnu.so +0 -0
  213. sage/graphs/spanning_tree.pyx +1457 -0
  214. sage/graphs/strongly_regular_db.cpython-39-aarch64-linux-gnu.so +0 -0
  215. sage/graphs/strongly_regular_db.pyx +3340 -0
  216. sage/graphs/traversals.cpython-39-aarch64-linux-gnu.so +0 -0
  217. sage/graphs/traversals.pxd +9 -0
  218. sage/graphs/traversals.pyx +1871 -0
  219. sage/graphs/trees.cpython-39-aarch64-linux-gnu.so +0 -0
  220. sage/graphs/trees.pxd +15 -0
  221. sage/graphs/trees.pyx +310 -0
  222. sage/graphs/tutte_polynomial.py +713 -0
  223. sage/graphs/views.cpython-39-aarch64-linux-gnu.so +0 -0
  224. sage/graphs/views.pyx +794 -0
  225. sage/graphs/weakly_chordal.cpython-39-aarch64-linux-gnu.so +0 -0
  226. sage/graphs/weakly_chordal.pyx +562 -0
  227. sage/groups/all__sagemath_graphs.py +1 -0
  228. sage/groups/perm_gps/all__sagemath_graphs.py +1 -0
  229. sage/groups/perm_gps/partn_ref/all__sagemath_graphs.py +1 -0
  230. sage/groups/perm_gps/partn_ref/refinement_graphs.cpython-39-aarch64-linux-gnu.so +0 -0
  231. sage/groups/perm_gps/partn_ref/refinement_graphs.pxd +38 -0
  232. sage/groups/perm_gps/partn_ref/refinement_graphs.pyx +1666 -0
  233. sage/knots/all.py +6 -0
  234. sage/knots/free_knotinfo_monoid.py +507 -0
  235. sage/knots/gauss_code.py +291 -0
  236. sage/knots/knot.py +682 -0
  237. sage/knots/knot_table.py +284 -0
  238. sage/knots/knotinfo.py +2880 -0
  239. sage/knots/link.py +4682 -0
  240. sage/sandpiles/all.py +13 -0
  241. sage/sandpiles/examples.py +225 -0
  242. sage/sandpiles/sandpile.py +6365 -0
  243. sage/topology/all.py +22 -0
  244. sage/topology/cell_complex.py +1214 -0
  245. sage/topology/cubical_complex.py +1977 -0
  246. sage/topology/delta_complex.py +1806 -0
  247. sage/topology/filtered_simplicial_complex.py +744 -0
  248. sage/topology/moment_angle_complex.py +823 -0
  249. sage/topology/simplicial_complex.py +5161 -0
  250. sage/topology/simplicial_complex_catalog.py +86 -0
  251. sage/topology/simplicial_complex_examples.py +1692 -0
  252. sage/topology/simplicial_complex_homset.py +205 -0
  253. sage/topology/simplicial_complex_morphism.py +836 -0
  254. sage/topology/simplicial_set.py +4102 -0
  255. sage/topology/simplicial_set_catalog.py +55 -0
  256. sage/topology/simplicial_set_constructions.py +2954 -0
  257. sage/topology/simplicial_set_examples.py +865 -0
  258. sage/topology/simplicial_set_morphism.py +1464 -0
@@ -0,0 +1,562 @@
1
+ # sage_setup: distribution = sagemath-graphs
2
+ # cython: binding=True
3
+ r"""
4
+ Weakly chordal graphs
5
+
6
+ This module deals with everything related to weakly chordal graphs. It currently
7
+ contains the following functions:
8
+
9
+ .. csv-table::
10
+ :class: contentstable
11
+ :widths: 30, 70
12
+ :delim: |
13
+
14
+ :meth:`~sage.graphs.weakly_chordal.is_long_hole_free` | Test whether ``g`` contains an induced cycle of length at least 5.
15
+ :meth:`~sage.graphs.weakly_chordal.is_long_antihole_free` | Test whether ``g`` contains an induced anticycle of length at least 5.
16
+ :meth:`~sage.graphs.weakly_chordal.is_weakly_chordal` | Test whether ``g`` is weakly chordal.
17
+
18
+ Author:
19
+
20
+ - Birk Eisermann (initial implementation)
21
+ - Nathann Cohen (some doc and optimization)
22
+ - David Coudert (remove recursion)
23
+
24
+
25
+ Methods
26
+ -------
27
+ """
28
+
29
+ # ****************************************************************************
30
+ # Copyright (c) 2012 Birk Eisermann <eisermbi@fastmail.fm>
31
+ #
32
+ # This program is free software: you can redistribute it and/or modify
33
+ # it under the terms of the GNU General Public License as published by
34
+ # the Free Software Foundation, either version 2 of the License, or
35
+ # (at your option) any later version.
36
+ # https://www.gnu.org/licenses/
37
+ # ****************************************************************************
38
+
39
+ from memory_allocator cimport MemoryAllocator
40
+ from sage.data_structures.bitset_base cimport *
41
+ from sage.graphs.base.static_sparse_graph cimport short_digraph
42
+ from sage.graphs.base.static_sparse_graph cimport init_short_digraph
43
+ from sage.graphs.base.static_sparse_graph cimport free_short_digraph
44
+ from sage.graphs.base.static_sparse_graph cimport out_degree
45
+
46
+
47
+ cdef inline int has_edge(bitset_t bs, int u, int v, int n) noexcept:
48
+ return bitset_in(bs, u * n + v)
49
+
50
+
51
+ cdef inline is_long_hole_free_process(g, short_digraph sd, bitset_t dense_graph,
52
+ list id_label, int* path, int* InPath,
53
+ int* neighbor_index, set VisitedP3,
54
+ bint certificate,
55
+ int a, int b, int c, int n):
56
+ """
57
+ This method is part of method ``is_long_hole_free``.
58
+
59
+ EXAMPLES::
60
+
61
+ sage: g = graphs.PetersenGraph()
62
+ sage: g.is_long_hole_free()
63
+ False
64
+ """
65
+ cdef int d, u, v, i
66
+ cdef Py_ssize_t path_top = 2
67
+ cdef list C
68
+ cdef dict C_index
69
+
70
+ path[2] = c
71
+ InPath[c] = path_top # c is the (i+1)-th vertex at position i
72
+ neighbor_index[c] = 0
73
+ VisitedP3.add((a, b, c))
74
+ VisitedP3.add((c, b, a))
75
+
76
+ while path_top >= 2:
77
+ a = path[path_top - 2]
78
+ b = path[path_top - 1]
79
+ c = path[path_top]
80
+
81
+ if neighbor_index[c] < out_degree(sd, c):
82
+ d = sd.neighbors[c][neighbor_index[c]]
83
+ neighbor_index[c] += 1
84
+ if not has_edge(dense_graph, d, a, n) and not has_edge(dense_graph, d, b, n):
85
+ # a-b-c-d form an induced path P_4
86
+
87
+ if InPath[d] != -1:
88
+ # d is already contained in InPath
89
+ # HOLE FOUND !!!
90
+ if certificate:
91
+ # We extract the hole and relabel it on-the-fly with the
92
+ # vertices' real name
93
+ C = [id_label[path[i]] for i in range(InPath[d], path_top + 1)]
94
+ C_index = {label: i for i, label in enumerate(C)}
95
+
96
+ # At this step C[0]C[1]..... is a cycle such that any 4
97
+ # consecutive vertices induce a P4. C may not be an
98
+ # induced cycle, so we extract one from it.
99
+
100
+ # To do so, we look for the *shortest* edge C[i]C[j]
101
+ # between two nonconsecutive vertices of C, where the
102
+ # length is the difference |i-j|.
103
+ #
104
+ # C[i]...C[j] is necessarily an induced cycle.
105
+
106
+ gg = g.subgraph(C, immutable=False)
107
+ gg.delete_edges(zip(C[:-1], C[1:]))
108
+
109
+ def dist(X):
110
+ return abs(C_index[X[0]] - C_index[X[1]])
111
+
112
+ label_u, label_v = min(gg.edge_iterator(labels=False), key=dist)
113
+ u, v = C_index[label_u], C_index[label_v]
114
+
115
+ # Return the answer
116
+ return False, g.subgraph(C[min(u, v): max(u, v) + 1])
117
+
118
+ else:
119
+ return False, None
120
+
121
+ elif (b, c, d) not in VisitedP3:
122
+ # search for another P_4
123
+ path_top += 1
124
+ path[path_top] = d
125
+ InPath[d] = path_top
126
+ neighbor_index[d] = 0
127
+ VisitedP3.add((b, c, d))
128
+ VisitedP3.add((d, c, b))
129
+
130
+ else:
131
+ # We are done with c. We trackback
132
+ path_top -= 1
133
+ InPath[c] = -1
134
+
135
+ return True, []
136
+
137
+
138
+ def is_long_hole_free(g, certificate=False):
139
+ r"""
140
+ Test whether ``g`` contains an induced cycle of length at least 5.
141
+
142
+ INPUT:
143
+
144
+ - ``certificate`` -- boolean (default: ``False``)
145
+
146
+ Whether to return a certificate. When ``certificate = True``, then
147
+ the function returns
148
+
149
+ * ``(True, [])`` if ``g`` does not contain such a cycle.
150
+ For this case, it is not known how to provide a certificate.
151
+ * ``(False, Hole)`` if ``g`` contains an induced cycle of length at
152
+ least 5. ``Hole`` returns this cycle.
153
+
154
+ If ``certificate = False``, the function returns just ``True`` or
155
+ ``False`` accordingly.
156
+
157
+ ALGORITHM:
158
+
159
+ This algorithm tries to find a cycle in the graph of all induced `P_4` of
160
+ `g`, where two copies `P` and `P'` of `P_4` are adjacent if there exists a
161
+ (not necessarily induced) copy of `P_5=u_1u_2u_3u_4u_5` such that
162
+ `P=u_1u_2u_3u_4` and `P'=u_2u_3u_4u_5`.
163
+
164
+ This is done through a depth-first-search. For efficiency, the auxiliary
165
+ graph is constructed on-the-fly and never stored in memory.
166
+
167
+ The run time of this algorithm is `O(n+m^2)` for ``SparseGraph`` and
168
+ `O(n^2 + m^2)` for ``DenseGraph`` [NP2007]_ (where `n` is the number of
169
+ vertices and `m` is the number of edges of the graph).
170
+
171
+ EXAMPLES:
172
+
173
+ The Petersen Graph contains a hole::
174
+
175
+ sage: g = graphs.PetersenGraph()
176
+ sage: g.is_long_hole_free()
177
+ False
178
+
179
+ The following graph contains a hole, which we want to display::
180
+
181
+ sage: g = graphs.FlowerSnark()
182
+ sage: r,h = g.is_long_hole_free(certificate=True)
183
+ sage: r
184
+ False
185
+ sage: Graph(h).is_isomorphic(graphs.CycleGraph(h.order()))
186
+ True
187
+
188
+ TESTS:
189
+
190
+ Another graph with vertices 2, ..., 8, 10::
191
+
192
+ sage: g = Graph({2:[3,8],3:[2,4],4:[3,8,10],5:[6,10],6:[5,7],7:[6,8],8:[2,4,7,10],10:[4,5,8]})
193
+ sage: r,hole = g.is_long_hole_free(certificate=True)
194
+ sage: r
195
+ False
196
+ sage: hole
197
+ Subgraph of (): Graph on 5 vertices
198
+ sage: hole.is_isomorphic(graphs.CycleGraph(hole.order()))
199
+ True
200
+
201
+ sage: graphs.EmptyGraph().is_long_hole_free()
202
+ True
203
+ """
204
+ g._scream_if_not_simple()
205
+
206
+ if g.order() < 5:
207
+ return (True, []) if certificate else True
208
+
209
+ cdef int u, v, w, vv, ww
210
+
211
+ # Make a copy of the graph as a short_digraph. This data structure is well
212
+ # documented in the module sage.graphs.base.static_sparse_graph.
213
+ # Vertices are relabeled in 0..n-1
214
+ cdef int n = g.order()
215
+ cdef list id_label = list(g)
216
+ cdef short_digraph sd
217
+ init_short_digraph(sd, g, edge_labelled=False, vertex_list=id_label)
218
+
219
+ # Make a dense copy of the graph for quick adjacency tests
220
+ cdef bitset_t dense_graph
221
+ bitset_init(dense_graph, n * n)
222
+ bitset_set_first_n(dense_graph, 0)
223
+ for u in range(n):
224
+ for vv in range(out_degree(sd, u)):
225
+ v = sd.neighbors[u][vv]
226
+ bitset_add(dense_graph, u * n + v)
227
+ bitset_add(dense_graph, v * n + u)
228
+
229
+ # Allocate some data structures
230
+ cdef MemoryAllocator mem = MemoryAllocator()
231
+ cdef int* path = <int*> mem.allocarray(n, sizeof(int))
232
+ cdef int* InPath = <int*> mem.allocarray(n, sizeof(int))
233
+ for u in range(n):
234
+ InPath[u] = -1
235
+
236
+ cdef int* neighbor_index = <int*> mem.allocarray(n, sizeof(int))
237
+
238
+ cdef set VisitedP3 = set() # stores triples (u,v,w) which represent visited paths of length 3
239
+
240
+ # main algorithm
241
+ # For all triples u,v,w of vertices such that uvw is a P_3
242
+ for u in range(n):
243
+ # u is the first vertex of the path, at position 0
244
+ path[0] = u
245
+ InPath[u] = 0
246
+ for vv in range(out_degree(sd, u)):
247
+ v = sd.neighbors[u][vv]
248
+ # v is the second vertex of the path, at position 1
249
+ path[1] = v
250
+ InPath[v] = 1
251
+ for ww in range(out_degree(sd, v)):
252
+ w = sd.neighbors[v][ww]
253
+ if u != w and not has_edge(dense_graph, u, w, n) and (u, v, w) not in VisitedP3:
254
+
255
+ res, hole = is_long_hole_free_process(g, sd, dense_graph, id_label,
256
+ path, InPath, neighbor_index, VisitedP3,
257
+ certificate, u, v, w, n)
258
+
259
+ if not res:
260
+ # We release memory before returning the result
261
+ free_short_digraph(sd)
262
+ bitset_free(dense_graph)
263
+
264
+ if certificate:
265
+ return False, hole
266
+ return False
267
+
268
+ InPath[v] = -1
269
+ InPath[u] = -1
270
+
271
+ # Release memory
272
+ free_short_digraph(sd)
273
+ bitset_free(dense_graph)
274
+
275
+ if certificate:
276
+ return True, []
277
+ return True
278
+
279
+
280
+ cdef inline is_long_antihole_free_process(g, short_digraph sd, bitset_t dense_graph,
281
+ list id_label, int* path, int* InPath,
282
+ int* neighbor_index, set VisitedP3,
283
+ bint certificate,
284
+ int a, int b, int c, int n):
285
+ """
286
+ This method is part of method ``is_long_antihole_free``.
287
+
288
+ EXAMPLES::
289
+
290
+ sage: g = graphs.PetersenGraph()
291
+ sage: g.is_long_antihole_free()
292
+ False
293
+ """
294
+ cdef int d, u, v, i
295
+ cdef Py_ssize_t path_top = 2
296
+ cdef list C
297
+ cdef dict C_index
298
+
299
+ path[2] = c
300
+ InPath[c] = 2 # c is the (i+1)-th vertex at position i
301
+ neighbor_index[b] = 0
302
+ VisitedP3.add((a, b, c))
303
+ VisitedP3.add((c, b, a))
304
+
305
+ while path_top >= 2:
306
+ # We consider the antichain a,b,c
307
+ a = path[path_top - 2]
308
+ b = path[path_top - 1]
309
+ c = path[path_top]
310
+
311
+ if neighbor_index[b] < out_degree(sd, b):
312
+ d = sd.neighbors[b][neighbor_index[b]]
313
+ neighbor_index[b] += 1
314
+ if has_edge(dense_graph, d, a, n) and not has_edge(dense_graph, d, c, n):
315
+ # We found a neighbor of a and b that is not adjacent to c
316
+ if InPath[d] != -1:
317
+ if certificate:
318
+ # Calculation of induced cycle in complement
319
+ # Relabel it on-the-fly with the vertices' real name
320
+ C = [id_label[path[i]] for i in range(InPath[d], path_top + 1)]
321
+ C_index = {label: i for i, label in enumerate(C)}
322
+
323
+ # At this step C[0]C[1]..... is an anticycle such that
324
+ # any 4 consecutive vertices induce the complement of a
325
+ # P4. C may not be an induced anticycle, so we extract
326
+ # one from it.
327
+
328
+ # To do so, we look for the *shortest* nonedge C[i]C[j]
329
+ # between two nonconsecutive vertices of C, where the
330
+ # length is the difference |i-j|.
331
+ #
332
+ # C[i]...C[j] is necessarily an induced anticycle.
333
+
334
+ gg = g.subgraph(C, immutable=False).complement()
335
+ gg.delete_edges(zip(C[:-1], C[1:]))
336
+
337
+ def dist(X):
338
+ return abs(C_index[X[0]] - C_index[X[1]])
339
+
340
+ label_u, label_v = min(gg.edge_iterator(labels=False), key=dist)
341
+ u, v = C_index[label_u], C_index[label_v]
342
+
343
+ # Return the answer
344
+ return False, g.subgraph(C[min(u, v): max(u, v) + 1])
345
+
346
+ else:
347
+ return False, []
348
+
349
+ elif (b, c, d) not in VisitedP3:
350
+ path_top += 1
351
+ path[path_top] = d
352
+ InPath[d] = path_top
353
+ neighbor_index[c] = 0
354
+ VisitedP3.add((b, c, d))
355
+ VisitedP3.add((d, c, b))
356
+
357
+ else:
358
+ # We trackback
359
+ path_top -= 1
360
+ InPath[c] = -1
361
+
362
+ return True, []
363
+
364
+
365
+ def is_long_antihole_free(g, certificate=False):
366
+ r"""
367
+ Test whether the given graph contains an induced subgraph that is
368
+ isomorphic to the complement of a cycle of length at least 5.
369
+
370
+ INPUT:
371
+
372
+ - ``certificate`` -- boolean (default: ``False``)
373
+
374
+ Whether to return a certificate. When ``certificate = True``, then
375
+ the function returns
376
+
377
+ * ``(False, Antihole)`` if ``g`` contains an induced complement
378
+ of a cycle of length at least 5 returned as ``Antihole``.
379
+ * ``(True, [])`` if ``g`` does not contain an induced complement of
380
+ a cycle of length at least 5.
381
+ For this case it is not known how to provide a certificate.
382
+
383
+ When ``certificate = False``, the function returns just ``True`` or
384
+ ``False`` accordingly.
385
+
386
+ ALGORITHM:
387
+
388
+ This algorithm tries to find a cycle in the graph of all induced
389
+ `\overline{P_4}` of `g`, where two copies `\overline{P}` and `\overline{P'}`
390
+ of `\overline{P_4}` are adjacent if there exists a (not necessarily induced)
391
+ copy of `\overline{P_5}=u_1u_2u_3u_4u_5` such that
392
+ `\overline{P}=u_1u_2u_3u_4` and `\overline{P'}=u_2u_3u_4u_5`.
393
+
394
+ This is done through a depth-first-search. For efficiency, the auxiliary
395
+ graph is constructed on-the-fly and never stored in memory.
396
+
397
+ The run time of this algorithm is `O(n+m^2)` for ``SparseGraph`` and
398
+ `O(n^2\log{m} + m^2)` for ``DenseGraph`` [NP2007]_ (where `n` is the number
399
+ of vertices and `m` is the number of edges of the graph).
400
+
401
+ EXAMPLES:
402
+
403
+ The Petersen Graph contains an antihole::
404
+
405
+ sage: g = graphs.PetersenGraph()
406
+ sage: g.is_long_antihole_free()
407
+ False
408
+
409
+ The complement of a cycle is an antihole::
410
+
411
+ sage: g = graphs.CycleGraph(6).complement()
412
+ sage: r,a = g.is_long_antihole_free(certificate=True)
413
+ sage: r
414
+ False
415
+ sage: a.complement().is_isomorphic(graphs.CycleGraph(6))
416
+ True
417
+
418
+ TESTS:
419
+
420
+ Further tests::
421
+
422
+ sage: g = Graph({0:[6,7],1:[7,8],2:[8,9],3:[9,10],4:[10,11],5:[11,6],6:[0,5,7],7:[0,1,6],8:[1,2,9],9:[2,3,8],10:[3,4,11],11:[4,5,10]}).complement()
423
+ sage: r,a = g.is_long_antihole_free(certificate=True)
424
+ sage: r
425
+ False
426
+ sage: a.complement().is_isomorphic(graphs.CycleGraph(9))
427
+ True
428
+
429
+ sage: graphs.EmptyGraph().is_long_hole_free()
430
+ True
431
+ """
432
+ g._scream_if_not_simple()
433
+
434
+ if g.order() < 5:
435
+ return (True, []) if certificate else True
436
+
437
+ cdef int u, v, w, vv, ww
438
+
439
+ # Make a copy of the graph as a short_digraph. This data structure is well
440
+ # documented in the module sage.graphs.base.static_sparse_graph.
441
+ # Vertices are relabeled in 0..n-1
442
+ cdef int n = g.order()
443
+ cdef list id_label = list(g)
444
+ cdef short_digraph sd
445
+ init_short_digraph(sd, g, edge_labelled=False, vertex_list=id_label)
446
+
447
+ # Make a dense copy of the graph for quick adjacency tests
448
+ cdef bitset_t dense_graph
449
+ bitset_init(dense_graph, n * n)
450
+ bitset_set_first_n(dense_graph, 0)
451
+ for u in range(n):
452
+ for vv in range(out_degree(sd, u)):
453
+ v = sd.neighbors[u][vv]
454
+ bitset_add(dense_graph, u * n + v)
455
+ bitset_add(dense_graph, v * n + u)
456
+
457
+ # Allocate some data structures
458
+ cdef MemoryAllocator mem = MemoryAllocator()
459
+ cdef int* path = <int*> mem.allocarray(n, sizeof(int))
460
+ cdef int* InPath = <int*> mem.allocarray(n, sizeof(int))
461
+ for u in range(n):
462
+ InPath[u] = -1
463
+
464
+ cdef int* neighbor_index = <int*> mem.allocarray(n, sizeof(int))
465
+
466
+ cdef set VisitedP3 = set() # stores triples (u,v,w) which represent visited paths of length 3
467
+
468
+ # main algorithm
469
+ # For all triples u,v,w of vertices such that uvw is a complement of P_3
470
+ for u in range(n):
471
+ # u is the first vertex of the path, at position 0
472
+ path[1] = u
473
+ InPath[u] = 1
474
+ for v in range(n):
475
+ if v == u or has_edge(dense_graph, u, v, n):
476
+ continue
477
+ path[0] = v
478
+ InPath[v] = 0
479
+ for ww in range(out_degree(sd, v)):
480
+ w = sd.neighbors[v][ww]
481
+ if v < w and not has_edge(dense_graph, u, w, n) and (v, u, w) not in VisitedP3:
482
+
483
+ res, antihole = is_long_antihole_free_process(g, sd, dense_graph, id_label,
484
+ path, InPath, neighbor_index,
485
+ VisitedP3, certificate,
486
+ v, u, w, n)
487
+
488
+ if not res:
489
+ # We release memory before returning the result
490
+ free_short_digraph(sd)
491
+ bitset_free(dense_graph)
492
+
493
+ if certificate:
494
+ return False, antihole
495
+ return False
496
+
497
+ InPath[v] = -1
498
+ InPath[u] = -1
499
+
500
+ # Release memory
501
+ free_short_digraph(sd)
502
+ bitset_free(dense_graph)
503
+
504
+ if certificate:
505
+ return True, []
506
+ return True
507
+
508
+
509
+ def is_weakly_chordal(g, certificate=False):
510
+ r"""
511
+ Test whether the given graph is weakly chordal, i.e., the graph and its
512
+ complement have no induced cycle of length at least 5.
513
+
514
+ INPUT:
515
+
516
+ - ``certificate`` -- boolean (default: ``False``); whether to
517
+ return a certificate. If ``certificate = False``, return ``True`` or
518
+ ``False`` according to the graph. If ``certificate = True``, return
519
+
520
+ * ``(False, forbidden_subgraph)`` when the graph contains a
521
+ forbidden subgraph H, this graph is returned.
522
+ * ``(True, [])`` when the graph is weakly chordal.
523
+ For this case, it is not known how to provide a certificate.
524
+
525
+ ALGORITHM:
526
+
527
+ This algorithm checks whether the graph ``g`` or its complement
528
+ contain an induced cycle of length at least 5.
529
+
530
+ Using is_long_hole_free() and is_long_antihole_free() yields a run time
531
+ of `O(n+m^2)` for ``SparseGraph`` and `O(n^2 + m^2)` for ``DenseGraph``
532
+ (where `n` is the number of vertices and `m` is the number of edges of the
533
+ graph).
534
+
535
+ EXAMPLES:
536
+
537
+ The Petersen Graph is not weakly chordal and contains a hole::
538
+
539
+ sage: g = graphs.PetersenGraph()
540
+ sage: r,s = g.is_weakly_chordal(certificate=True)
541
+ sage: r
542
+ False
543
+ sage: l = s.order()
544
+ sage: s.is_isomorphic(graphs.CycleGraph(l))
545
+ True
546
+
547
+ TESTS::
548
+
549
+ sage: graphs.EmptyGraph().is_weakly_chordal()
550
+ True
551
+ """
552
+ if g.order() < 5:
553
+ return (True, []) if certificate else True
554
+
555
+ if certificate:
556
+ r, forbid_subgr = g.is_long_hole_free(certificate=True)
557
+ if not r:
558
+ return False, forbid_subgr
559
+
560
+ return g.is_long_antihole_free(certificate=True)
561
+
562
+ return g.is_long_hole_free() and g.is_long_antihole_free()
@@ -0,0 +1 @@
1
+ # sage_setup: distribution = sagemath-graphs
@@ -0,0 +1 @@
1
+ # sage_setup: distribution = sagemath-graphs
@@ -0,0 +1 @@
1
+ # sage_setup: distribution = sagemath-graphs
@@ -0,0 +1,38 @@
1
+ # sage_setup: distribution = sagemath-graphs
2
+ #*****************************************************************************
3
+ # Copyright (C) 2006 - 2011 Robert L. Miller <rlmillster@gmail.com>
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 2 of the License, or
8
+ # (at your option) any later version.
9
+ # http://www.gnu.org/licenses/
10
+ #*****************************************************************************
11
+
12
+ from sage.groups.perm_gps.partn_ref.data_structures cimport *
13
+ from sage.graphs.base.c_graph cimport CGraph
14
+ from sage.groups.perm_gps.partn_ref.automorphism_group_canonical_label cimport (
15
+ get_aut_gp_and_can_lab, aut_gp_and_can_lab, agcl_work_space,
16
+ allocate_agcl_output, deallocate_agcl_output,
17
+ allocate_agcl_work_space, deallocate_agcl_work_space)
18
+ from sage.groups.perm_gps.partn_ref.canonical_augmentation cimport (iterator,
19
+ canonical_generator_data, allocate_cgd, deallocate_cgd,
20
+ canonical_generator_next,
21
+ setup_canonical_generator, start_canonical_generator)
22
+ from sage.groups.perm_gps.partn_ref.refinement_sets cimport (subset, free_subset, all_set_children_are_equivalent,
23
+ refine_set, compare_sets, generate_child_subsets, apply_subset_aug,
24
+ canonical_set_parent, allocate_sgd, deallocate_sgd, allocate_subset_gen, free_subset_gen,
25
+ setup_set_gen, subset_generator_next, subset_generator_data, allocate_subset_gen_2)
26
+
27
+
28
+ cdef class GraphStruct:
29
+ cdef CGraph G
30
+ cdef bint directed
31
+ cdef bint loops
32
+ cdef bint use_indicator
33
+ cdef int *scratch # length 3n+1
34
+
35
+
36
+ cdef struct dg_edge_gen_data:
37
+ iterator *edge_iterator
38
+ void *graph