passagemath-combinat 10.6.42__cp314-cp314-musllinux_1_2_x86_64.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.
- passagemath_combinat/__init__.py +3 -0
- passagemath_combinat-10.6.42.dist-info/METADATA +160 -0
- passagemath_combinat-10.6.42.dist-info/RECORD +400 -0
- passagemath_combinat-10.6.42.dist-info/WHEEL +5 -0
- passagemath_combinat-10.6.42.dist-info/top_level.txt +3 -0
- passagemath_combinat.libs/libgmp-0e7fc84e.so.10.5.0 +0 -0
- passagemath_combinat.libs/libsymmetrica-81fe8739.so.3.0.0 +0 -0
- sage/algebras/affine_nil_temperley_lieb.py +263 -0
- sage/algebras/all.py +24 -0
- sage/algebras/all__sagemath_combinat.py +35 -0
- sage/algebras/askey_wilson.py +935 -0
- sage/algebras/associated_graded.py +345 -0
- sage/algebras/cellular_basis.py +350 -0
- sage/algebras/cluster_algebra.py +2766 -0
- sage/algebras/down_up_algebra.py +860 -0
- sage/algebras/free_algebra.py +1698 -0
- sage/algebras/free_algebra_element.py +345 -0
- sage/algebras/free_algebra_quotient.py +405 -0
- sage/algebras/free_algebra_quotient_element.py +295 -0
- sage/algebras/free_zinbiel_algebra.py +885 -0
- sage/algebras/hall_algebra.py +783 -0
- sage/algebras/hecke_algebras/all.py +4 -0
- sage/algebras/hecke_algebras/ariki_koike_algebra.py +1796 -0
- sage/algebras/hecke_algebras/ariki_koike_specht_modules.py +475 -0
- sage/algebras/hecke_algebras/cubic_hecke_algebra.py +3520 -0
- sage/algebras/hecke_algebras/cubic_hecke_base_ring.py +1473 -0
- sage/algebras/hecke_algebras/cubic_hecke_matrix_rep.py +1079 -0
- sage/algebras/iwahori_hecke_algebra.py +3095 -0
- sage/algebras/jordan_algebra.py +1773 -0
- sage/algebras/lie_conformal_algebras/abelian_lie_conformal_algebra.py +113 -0
- sage/algebras/lie_conformal_algebras/affine_lie_conformal_algebra.py +156 -0
- sage/algebras/lie_conformal_algebras/all.py +18 -0
- sage/algebras/lie_conformal_algebras/bosonic_ghosts_lie_conformal_algebra.py +134 -0
- sage/algebras/lie_conformal_algebras/examples.py +43 -0
- sage/algebras/lie_conformal_algebras/fermionic_ghosts_lie_conformal_algebra.py +131 -0
- sage/algebras/lie_conformal_algebras/finitely_freely_generated_lca.py +139 -0
- sage/algebras/lie_conformal_algebras/free_bosons_lie_conformal_algebra.py +174 -0
- sage/algebras/lie_conformal_algebras/free_fermions_lie_conformal_algebra.py +167 -0
- sage/algebras/lie_conformal_algebras/freely_generated_lie_conformal_algebra.py +107 -0
- sage/algebras/lie_conformal_algebras/graded_lie_conformal_algebra.py +135 -0
- sage/algebras/lie_conformal_algebras/lie_conformal_algebra.py +353 -0
- sage/algebras/lie_conformal_algebras/lie_conformal_algebra_element.py +236 -0
- sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_basis.py +78 -0
- sage/algebras/lie_conformal_algebras/lie_conformal_algebra_with_structure_coefs.py +328 -0
- sage/algebras/lie_conformal_algebras/n2_lie_conformal_algebra.py +117 -0
- sage/algebras/lie_conformal_algebras/neveu_schwarz_lie_conformal_algebra.py +86 -0
- sage/algebras/lie_conformal_algebras/virasoro_lie_conformal_algebra.py +82 -0
- sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py +205 -0
- sage/algebras/nil_coxeter_algebra.py +191 -0
- sage/algebras/q_commuting_polynomials.py +673 -0
- sage/algebras/q_system.py +608 -0
- sage/algebras/quantum_clifford.py +959 -0
- sage/algebras/quantum_groups/ace_quantum_onsager.py +693 -0
- sage/algebras/quantum_groups/all.py +9 -0
- sage/algebras/quantum_groups/fock_space.py +2219 -0
- sage/algebras/quantum_groups/q_numbers.py +207 -0
- sage/algebras/quantum_groups/quantum_group_gap.py +2695 -0
- sage/algebras/quantum_groups/representations.py +591 -0
- sage/algebras/quantum_matrix_coordinate_algebra.py +1006 -0
- sage/algebras/quantum_oscillator.py +623 -0
- sage/algebras/quaternion_algebra.py +20 -0
- sage/algebras/quaternion_algebra_element.py +55 -0
- sage/algebras/rational_cherednik_algebra.py +525 -0
- sage/algebras/schur_algebra.py +670 -0
- sage/algebras/shuffle_algebra.py +1011 -0
- sage/algebras/splitting_algebra.py +779 -0
- sage/algebras/tensor_algebra.py +709 -0
- sage/algebras/yangian.py +1082 -0
- sage/algebras/yokonuma_hecke_algebra.py +1018 -0
- sage/all__sagemath_combinat.py +35 -0
- sage/combinat/SJT.py +255 -0
- sage/combinat/affine_permutation.py +2405 -0
- sage/combinat/algebraic_combinatorics.py +55 -0
- sage/combinat/all.py +53 -0
- sage/combinat/all__sagemath_combinat.py +195 -0
- sage/combinat/alternating_sign_matrix.py +2063 -0
- sage/combinat/baxter_permutations.py +346 -0
- sage/combinat/bijectionist.py +3220 -0
- sage/combinat/binary_recurrence_sequences.py +1180 -0
- sage/combinat/blob_algebra.py +685 -0
- sage/combinat/catalog_partitions.py +27 -0
- sage/combinat/chas/all.py +23 -0
- sage/combinat/chas/fsym.py +1180 -0
- sage/combinat/chas/wqsym.py +2601 -0
- sage/combinat/cluster_complex.py +326 -0
- sage/combinat/colored_permutations.py +2039 -0
- sage/combinat/colored_permutations_representations.py +964 -0
- sage/combinat/composition_signed.py +142 -0
- sage/combinat/composition_tableau.py +855 -0
- sage/combinat/constellation.py +1729 -0
- sage/combinat/core.py +751 -0
- sage/combinat/counting.py +12 -0
- sage/combinat/crystals/affine.py +742 -0
- sage/combinat/crystals/affine_factorization.py +518 -0
- sage/combinat/crystals/affinization.py +331 -0
- sage/combinat/crystals/alcove_path.py +2013 -0
- sage/combinat/crystals/all.py +22 -0
- sage/combinat/crystals/bkk_crystals.py +141 -0
- sage/combinat/crystals/catalog.py +115 -0
- sage/combinat/crystals/catalog_elementary_crystals.py +18 -0
- sage/combinat/crystals/catalog_infinity_crystals.py +33 -0
- sage/combinat/crystals/catalog_kirillov_reshetikhin.py +18 -0
- sage/combinat/crystals/crystals.py +257 -0
- sage/combinat/crystals/direct_sum.py +260 -0
- sage/combinat/crystals/elementary_crystals.py +1251 -0
- sage/combinat/crystals/fast_crystals.py +441 -0
- sage/combinat/crystals/fully_commutative_stable_grothendieck.py +1205 -0
- sage/combinat/crystals/generalized_young_walls.py +1076 -0
- sage/combinat/crystals/highest_weight_crystals.py +436 -0
- sage/combinat/crystals/induced_structure.py +695 -0
- sage/combinat/crystals/infinity_crystals.py +730 -0
- sage/combinat/crystals/kac_modules.py +863 -0
- sage/combinat/crystals/kirillov_reshetikhin.py +4196 -0
- sage/combinat/crystals/kyoto_path_model.py +497 -0
- sage/combinat/crystals/letters.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/crystals/letters.pxd +79 -0
- sage/combinat/crystals/letters.pyx +3056 -0
- sage/combinat/crystals/littelmann_path.py +1518 -0
- sage/combinat/crystals/monomial_crystals.py +1262 -0
- sage/combinat/crystals/multisegments.py +462 -0
- sage/combinat/crystals/mv_polytopes.py +467 -0
- sage/combinat/crystals/pbw_crystal.py +511 -0
- sage/combinat/crystals/pbw_datum.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/crystals/pbw_datum.pxd +4 -0
- sage/combinat/crystals/pbw_datum.pyx +487 -0
- sage/combinat/crystals/polyhedral_realization.py +372 -0
- sage/combinat/crystals/spins.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/crystals/spins.pxd +21 -0
- sage/combinat/crystals/spins.pyx +756 -0
- sage/combinat/crystals/star_crystal.py +290 -0
- sage/combinat/crystals/subcrystal.py +464 -0
- sage/combinat/crystals/tensor_product.py +1177 -0
- sage/combinat/crystals/tensor_product_element.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/crystals/tensor_product_element.pxd +35 -0
- sage/combinat/crystals/tensor_product_element.pyx +1870 -0
- sage/combinat/crystals/virtual_crystal.py +420 -0
- sage/combinat/cyclic_sieving_phenomenon.py +204 -0
- sage/combinat/debruijn_sequence.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/debruijn_sequence.pyx +355 -0
- sage/combinat/decorated_permutation.py +270 -0
- sage/combinat/degree_sequences.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/degree_sequences.pyx +588 -0
- sage/combinat/derangements.py +527 -0
- sage/combinat/descent_algebra.py +1008 -0
- sage/combinat/diagram.py +1551 -0
- sage/combinat/diagram_algebras.py +5886 -0
- sage/combinat/dyck_word.py +4349 -0
- sage/combinat/e_one_star.py +1623 -0
- sage/combinat/enumerated_sets.py +123 -0
- sage/combinat/expnums.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/expnums.pyx +148 -0
- sage/combinat/fast_vector_partitions.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/fast_vector_partitions.pyx +346 -0
- sage/combinat/fqsym.py +1977 -0
- sage/combinat/free_dendriform_algebra.py +954 -0
- sage/combinat/free_prelie_algebra.py +1141 -0
- sage/combinat/fully_commutative_elements.py +1077 -0
- sage/combinat/fully_packed_loop.py +1523 -0
- sage/combinat/gelfand_tsetlin_patterns.py +1409 -0
- sage/combinat/gray_codes.py +311 -0
- sage/combinat/grossman_larson_algebras.py +667 -0
- sage/combinat/growth.py +4352 -0
- sage/combinat/hall_polynomial.py +188 -0
- sage/combinat/hillman_grassl.py +866 -0
- sage/combinat/integer_matrices.py +329 -0
- sage/combinat/integer_vectors_mod_permgroup.py +1238 -0
- sage/combinat/k_tableau.py +4564 -0
- sage/combinat/kazhdan_lusztig.py +215 -0
- sage/combinat/key_polynomial.py +885 -0
- sage/combinat/knutson_tao_puzzles.py +2286 -0
- sage/combinat/lr_tableau.py +311 -0
- sage/combinat/matrices/all.py +24 -0
- sage/combinat/matrices/hadamard_matrix.py +3790 -0
- sage/combinat/matrices/latin.py +2912 -0
- sage/combinat/misc.py +401 -0
- sage/combinat/multiset_partition_into_sets_ordered.py +3541 -0
- sage/combinat/ncsf_qsym/all.py +21 -0
- sage/combinat/ncsf_qsym/combinatorics.py +317 -0
- sage/combinat/ncsf_qsym/generic_basis_code.py +1427 -0
- sage/combinat/ncsf_qsym/ncsf.py +5637 -0
- sage/combinat/ncsf_qsym/qsym.py +4053 -0
- sage/combinat/ncsf_qsym/tutorial.py +447 -0
- sage/combinat/ncsym/all.py +21 -0
- sage/combinat/ncsym/bases.py +855 -0
- sage/combinat/ncsym/dual.py +593 -0
- sage/combinat/ncsym/ncsym.py +2076 -0
- sage/combinat/necklace.py +551 -0
- sage/combinat/non_decreasing_parking_function.py +634 -0
- sage/combinat/nu_dyck_word.py +1474 -0
- sage/combinat/output.py +861 -0
- sage/combinat/parallelogram_polyomino.py +4326 -0
- sage/combinat/parking_functions.py +1602 -0
- sage/combinat/partition_algebra.py +1998 -0
- sage/combinat/partition_kleshchev.py +1982 -0
- sage/combinat/partition_shifting_algebras.py +584 -0
- sage/combinat/partition_tuple.py +3114 -0
- sage/combinat/path_tableaux/all.py +13 -0
- sage/combinat/path_tableaux/catalog.py +29 -0
- sage/combinat/path_tableaux/dyck_path.py +380 -0
- sage/combinat/path_tableaux/frieze.py +476 -0
- sage/combinat/path_tableaux/path_tableau.py +728 -0
- sage/combinat/path_tableaux/semistandard.py +510 -0
- sage/combinat/perfect_matching.py +779 -0
- sage/combinat/plane_partition.py +3300 -0
- sage/combinat/q_bernoulli.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/q_bernoulli.pyx +128 -0
- sage/combinat/quickref.py +81 -0
- sage/combinat/recognizable_series.py +2051 -0
- sage/combinat/regular_sequence.py +4316 -0
- sage/combinat/regular_sequence_bounded.py +543 -0
- sage/combinat/restricted_growth.py +81 -0
- sage/combinat/ribbon.py +20 -0
- sage/combinat/ribbon_shaped_tableau.py +489 -0
- sage/combinat/ribbon_tableau.py +1180 -0
- sage/combinat/rigged_configurations/all.py +46 -0
- sage/combinat/rigged_configurations/bij_abstract_class.py +548 -0
- sage/combinat/rigged_configurations/bij_infinity.py +370 -0
- sage/combinat/rigged_configurations/bij_type_A.py +163 -0
- sage/combinat/rigged_configurations/bij_type_A2_dual.py +338 -0
- sage/combinat/rigged_configurations/bij_type_A2_even.py +218 -0
- sage/combinat/rigged_configurations/bij_type_A2_odd.py +199 -0
- sage/combinat/rigged_configurations/bij_type_B.py +900 -0
- sage/combinat/rigged_configurations/bij_type_C.py +267 -0
- sage/combinat/rigged_configurations/bij_type_D.py +771 -0
- sage/combinat/rigged_configurations/bij_type_D_tri.py +392 -0
- sage/combinat/rigged_configurations/bij_type_D_twisted.py +576 -0
- sage/combinat/rigged_configurations/bij_type_E67.py +402 -0
- sage/combinat/rigged_configurations/bijection.py +143 -0
- sage/combinat/rigged_configurations/kleber_tree.py +1475 -0
- sage/combinat/rigged_configurations/kr_tableaux.py +1898 -0
- sage/combinat/rigged_configurations/rc_crystal.py +461 -0
- sage/combinat/rigged_configurations/rc_infinity.py +540 -0
- sage/combinat/rigged_configurations/rigged_configuration_element.py +2403 -0
- sage/combinat/rigged_configurations/rigged_configurations.py +1918 -0
- sage/combinat/rigged_configurations/rigged_partition.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/rigged_configurations/rigged_partition.pxd +15 -0
- sage/combinat/rigged_configurations/rigged_partition.pyx +680 -0
- sage/combinat/rigged_configurations/tensor_product_kr_tableaux.py +499 -0
- sage/combinat/rigged_configurations/tensor_product_kr_tableaux_element.py +428 -0
- sage/combinat/rsk.py +3438 -0
- sage/combinat/schubert_polynomial.py +508 -0
- sage/combinat/set_partition.py +3318 -0
- sage/combinat/set_partition_iterator.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/set_partition_iterator.pyx +136 -0
- sage/combinat/set_partition_ordered.py +1590 -0
- sage/combinat/sf/abreu_nigro.py +346 -0
- sage/combinat/sf/all.py +52 -0
- sage/combinat/sf/character.py +576 -0
- sage/combinat/sf/classical.py +319 -0
- sage/combinat/sf/dual.py +996 -0
- sage/combinat/sf/elementary.py +549 -0
- sage/combinat/sf/hall_littlewood.py +1028 -0
- sage/combinat/sf/hecke.py +336 -0
- sage/combinat/sf/homogeneous.py +464 -0
- sage/combinat/sf/jack.py +1428 -0
- sage/combinat/sf/k_dual.py +1458 -0
- sage/combinat/sf/kfpoly.py +447 -0
- sage/combinat/sf/llt.py +789 -0
- sage/combinat/sf/macdonald.py +2019 -0
- sage/combinat/sf/monomial.py +525 -0
- sage/combinat/sf/multiplicative.py +113 -0
- sage/combinat/sf/new_kschur.py +1786 -0
- sage/combinat/sf/ns_macdonald.py +964 -0
- sage/combinat/sf/orthogonal.py +246 -0
- sage/combinat/sf/orthotriang.py +355 -0
- sage/combinat/sf/powersum.py +963 -0
- sage/combinat/sf/schur.py +880 -0
- sage/combinat/sf/sf.py +1653 -0
- sage/combinat/sf/sfa.py +7053 -0
- sage/combinat/sf/symplectic.py +253 -0
- sage/combinat/sf/witt.py +721 -0
- sage/combinat/shifted_primed_tableau.py +2735 -0
- sage/combinat/shuffle.py +830 -0
- sage/combinat/sidon_sets.py +146 -0
- sage/combinat/similarity_class_type.py +1721 -0
- sage/combinat/sine_gordon.py +618 -0
- sage/combinat/six_vertex_model.py +784 -0
- sage/combinat/skew_partition.py +2053 -0
- sage/combinat/skew_tableau.py +2989 -0
- sage/combinat/sloane_functions.py +8935 -0
- sage/combinat/specht_module.py +1403 -0
- sage/combinat/species/all.py +48 -0
- sage/combinat/species/characteristic_species.py +321 -0
- sage/combinat/species/composition_species.py +273 -0
- sage/combinat/species/cycle_species.py +284 -0
- sage/combinat/species/empty_species.py +155 -0
- sage/combinat/species/functorial_composition_species.py +148 -0
- sage/combinat/species/generating_series.py +673 -0
- sage/combinat/species/library.py +148 -0
- sage/combinat/species/linear_order_species.py +169 -0
- sage/combinat/species/misc.py +83 -0
- sage/combinat/species/partition_species.py +290 -0
- sage/combinat/species/permutation_species.py +268 -0
- sage/combinat/species/product_species.py +423 -0
- sage/combinat/species/recursive_species.py +476 -0
- sage/combinat/species/set_species.py +192 -0
- sage/combinat/species/species.py +820 -0
- sage/combinat/species/structure.py +539 -0
- sage/combinat/species/subset_species.py +243 -0
- sage/combinat/species/sum_species.py +225 -0
- sage/combinat/subword.py +564 -0
- sage/combinat/subword_complex.py +2122 -0
- sage/combinat/subword_complex_c.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/subword_complex_c.pyx +119 -0
- sage/combinat/super_tableau.py +821 -0
- sage/combinat/superpartition.py +1154 -0
- sage/combinat/symmetric_group_algebra.py +3774 -0
- sage/combinat/symmetric_group_representations.py +1830 -0
- sage/combinat/t_sequences.py +877 -0
- sage/combinat/tableau.py +9506 -0
- sage/combinat/tableau_residues.py +860 -0
- sage/combinat/tableau_tuple.py +5353 -0
- sage/combinat/tiling.py +2432 -0
- sage/combinat/triangles_FHM.py +777 -0
- sage/combinat/tutorial.py +1857 -0
- sage/combinat/vector_partition.py +337 -0
- sage/combinat/words/abstract_word.py +1722 -0
- sage/combinat/words/all.py +59 -0
- sage/combinat/words/alphabet.py +268 -0
- sage/combinat/words/finite_word.py +7201 -0
- sage/combinat/words/infinite_word.py +113 -0
- sage/combinat/words/lyndon_word.py +652 -0
- sage/combinat/words/morphic.py +351 -0
- sage/combinat/words/morphism.py +3878 -0
- sage/combinat/words/paths.py +2932 -0
- sage/combinat/words/shuffle_product.py +278 -0
- sage/combinat/words/suffix_trees.py +1873 -0
- sage/combinat/words/word.py +769 -0
- sage/combinat/words/word_char.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/words/word_char.pyx +847 -0
- sage/combinat/words/word_datatypes.cpython-314-x86_64-linux-musl.so +0 -0
- sage/combinat/words/word_datatypes.pxd +4 -0
- sage/combinat/words/word_datatypes.pyx +1067 -0
- sage/combinat/words/word_generators.py +2026 -0
- sage/combinat/words/word_infinite_datatypes.py +1218 -0
- sage/combinat/words/word_options.py +99 -0
- sage/combinat/words/words.py +2396 -0
- sage/data_structures/all__sagemath_combinat.py +1 -0
- sage/databases/all__sagemath_combinat.py +13 -0
- sage/databases/findstat.py +4897 -0
- sage/databases/oeis.py +2058 -0
- sage/databases/sloane.py +393 -0
- sage/dynamics/all__sagemath_combinat.py +14 -0
- sage/dynamics/cellular_automata/all.py +7 -0
- sage/dynamics/cellular_automata/catalog.py +34 -0
- sage/dynamics/cellular_automata/elementary.py +612 -0
- sage/dynamics/cellular_automata/glca.py +477 -0
- sage/dynamics/cellular_automata/solitons.py +1463 -0
- sage/dynamics/finite_dynamical_system.py +1249 -0
- sage/dynamics/finite_dynamical_system_catalog.py +382 -0
- sage/games/all.py +7 -0
- sage/games/hexad.py +704 -0
- sage/games/quantumino.py +591 -0
- sage/games/sudoku.py +889 -0
- sage/games/sudoku_backtrack.cpython-314-x86_64-linux-musl.so +0 -0
- sage/games/sudoku_backtrack.pyx +189 -0
- sage/groups/all__sagemath_combinat.py +1 -0
- sage/groups/indexed_free_group.py +489 -0
- sage/libs/all__sagemath_combinat.py +6 -0
- sage/libs/lrcalc/__init__.py +1 -0
- sage/libs/lrcalc/lrcalc.py +525 -0
- sage/libs/symmetrica/__init__.py +7 -0
- sage/libs/symmetrica/all.py +101 -0
- sage/libs/symmetrica/kostka.pxi +168 -0
- sage/libs/symmetrica/part.pxi +193 -0
- sage/libs/symmetrica/plet.pxi +42 -0
- sage/libs/symmetrica/sab.pxi +196 -0
- sage/libs/symmetrica/sb.pxi +332 -0
- sage/libs/symmetrica/sc.pxi +192 -0
- sage/libs/symmetrica/schur.pxi +956 -0
- sage/libs/symmetrica/symmetrica.cpython-314-x86_64-linux-musl.so +0 -0
- sage/libs/symmetrica/symmetrica.pxi +1172 -0
- sage/libs/symmetrica/symmetrica.pyx +39 -0
- sage/monoids/all.py +13 -0
- sage/monoids/automatic_semigroup.py +1054 -0
- sage/monoids/free_abelian_monoid.py +315 -0
- sage/monoids/free_abelian_monoid_element.cpython-314-x86_64-linux-musl.so +0 -0
- sage/monoids/free_abelian_monoid_element.pxd +16 -0
- sage/monoids/free_abelian_monoid_element.pyx +397 -0
- sage/monoids/free_monoid.py +335 -0
- sage/monoids/free_monoid_element.py +431 -0
- sage/monoids/hecke_monoid.py +65 -0
- sage/monoids/string_monoid.py +817 -0
- sage/monoids/string_monoid_element.py +547 -0
- sage/monoids/string_ops.py +143 -0
- sage/monoids/trace_monoid.py +972 -0
- sage/rings/all__sagemath_combinat.py +2 -0
- sage/sat/all.py +4 -0
- sage/sat/boolean_polynomials.py +405 -0
- sage/sat/converters/__init__.py +6 -0
- sage/sat/converters/anf2cnf.py +14 -0
- sage/sat/converters/polybori.py +611 -0
- sage/sat/solvers/__init__.py +5 -0
- sage/sat/solvers/cryptominisat.py +287 -0
- sage/sat/solvers/dimacs.py +783 -0
- sage/sat/solvers/picosat.py +228 -0
- sage/sat/solvers/sat_lp.py +156 -0
- sage/sat/solvers/satsolver.cpython-314-x86_64-linux-musl.so +0 -0
- sage/sat/solvers/satsolver.pxd +3 -0
- sage/sat/solvers/satsolver.pyx +405 -0
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-combinat
|
|
2
|
+
r"""
|
|
3
|
+
Degree sequences
|
|
4
|
+
|
|
5
|
+
The present module implements the ``DegreeSequences`` class, whose instances
|
|
6
|
+
represent the integer sequences of length `n`::
|
|
7
|
+
|
|
8
|
+
sage: DegreeSequences(6)
|
|
9
|
+
Degree sequences on 6 elements
|
|
10
|
+
|
|
11
|
+
With the object ``DegreeSequences(n)``, one can:
|
|
12
|
+
|
|
13
|
+
* Check whether a sequence is indeed a degree sequence::
|
|
14
|
+
|
|
15
|
+
sage: DS = DegreeSequences(5)
|
|
16
|
+
sage: [4, 3, 3, 3, 3] in DS
|
|
17
|
+
True
|
|
18
|
+
sage: [4, 4, 0, 0, 0] in DS
|
|
19
|
+
False
|
|
20
|
+
|
|
21
|
+
* List all the possible degree sequences of length `n`::
|
|
22
|
+
|
|
23
|
+
sage: for seq in DegreeSequences(4):
|
|
24
|
+
....: print(seq)
|
|
25
|
+
[0, 0, 0, 0]
|
|
26
|
+
[1, 1, 0, 0]
|
|
27
|
+
[2, 1, 1, 0]
|
|
28
|
+
[3, 1, 1, 1]
|
|
29
|
+
[1, 1, 1, 1]
|
|
30
|
+
[2, 2, 1, 1]
|
|
31
|
+
[2, 2, 2, 0]
|
|
32
|
+
[3, 2, 2, 1]
|
|
33
|
+
[2, 2, 2, 2]
|
|
34
|
+
[3, 3, 2, 2]
|
|
35
|
+
[3, 3, 3, 3]
|
|
36
|
+
|
|
37
|
+
.. NOTE::
|
|
38
|
+
|
|
39
|
+
Given a degree sequence, one can obtain a graph realizing it by using
|
|
40
|
+
:func:`~sage.graphs.generators.degree_sequence.DegreeSequence`.
|
|
41
|
+
For instance::
|
|
42
|
+
|
|
43
|
+
sage: ds = [3, 3, 2, 2, 2, 2, 2, 1, 1, 0]
|
|
44
|
+
sage: g = graphs.DegreeSequence(ds) # needs networkx sage.graphs
|
|
45
|
+
sage: g.degree_sequence() # needs networkx sage.graphs
|
|
46
|
+
[3, 3, 2, 2, 2, 2, 2, 1, 1, 0]
|
|
47
|
+
|
|
48
|
+
Definitions
|
|
49
|
+
~~~~~~~~~~~
|
|
50
|
+
|
|
51
|
+
A sequence of integers `d_1,...,d_n` is said to be a *degree sequence* (or
|
|
52
|
+
*graphic* sequence) if there exists a graph in which vertex `i` is of degree
|
|
53
|
+
`d_i`. It is often required to be *non-increasing*, i.e. that
|
|
54
|
+
`d_1 \geq ... \geq d_n`. Finding a graph with given degree sequence is
|
|
55
|
+
known as *graph realization problem*.
|
|
56
|
+
|
|
57
|
+
An integer sequence need not necessarily be a degree sequence. Indeed, in a
|
|
58
|
+
degree sequence of length `n` no integer can be larger than `n-1` -- the degree
|
|
59
|
+
of a vertex is at most `n-1` -- and the sum of them is at most `n(n-1)`.
|
|
60
|
+
|
|
61
|
+
Degree sequences are completely characterized by a result from Erdős and Gallai:
|
|
62
|
+
|
|
63
|
+
**Erdős and Gallai:** *The sequence of integers* `d_1 \geq \cdots \geq d_n`
|
|
64
|
+
*is a degree sequence if and only if* `\sum_i d_i` is even and `\forall i`
|
|
65
|
+
|
|
66
|
+
.. MATH::
|
|
67
|
+
|
|
68
|
+
\sum_{j\leq i}d_j \leq j(j-1) + \sum_{j>i} \min(d_j,i).
|
|
69
|
+
|
|
70
|
+
Alternatively, a degree sequence can be defined recursively:
|
|
71
|
+
|
|
72
|
+
**Havel and Hakimi:** *The sequence of integers* `d_1\geq ... \geq d_n` *is a
|
|
73
|
+
degree sequence if and only if* `d_2-1,...,d_{d_1+1}-1, d_{d_1+2}, ...,d_n` *is
|
|
74
|
+
also a degree sequence.*
|
|
75
|
+
|
|
76
|
+
Or equivalently:
|
|
77
|
+
|
|
78
|
+
**Havel and Hakimi (bis):** *If there is a realization of an integer sequence as
|
|
79
|
+
a graph (i.e. if the sequence is a degree sequence), then it can be realized in
|
|
80
|
+
such a way that the vertex of maximum degree* `\Delta` *is adjacent to the*
|
|
81
|
+
`\Delta` *vertices of highest degree (except itself, of course).*
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
Algorithms
|
|
85
|
+
~~~~~~~~~~
|
|
86
|
+
|
|
87
|
+
**Checking whether a given sequence is a degree sequence**
|
|
88
|
+
|
|
89
|
+
This is tested using Erdos and Gallai's criterion. It is also checked that the
|
|
90
|
+
given sequence is non-increasing and has length `n`.
|
|
91
|
+
|
|
92
|
+
**Iterating through the sequences of length** `n`
|
|
93
|
+
|
|
94
|
+
From Havel and Hakimi's recursive definition of a degree sequence, one can
|
|
95
|
+
build an enumeration algorithm as done in [RCES1994]_. It consists in
|
|
96
|
+
trying to **extend** a current degree sequence on `n` elements into a
|
|
97
|
+
degree sequence on `n+1` elements by adding a vertex of degree larger
|
|
98
|
+
than those already present in the sequence. This can be seen as **reversing**
|
|
99
|
+
the reduction operation described in Havel and Hakimi's characterization.
|
|
100
|
+
This operation can appear in several different ways:
|
|
101
|
+
|
|
102
|
+
* Extensions of a degree sequence that do **not** change the value of the
|
|
103
|
+
maximum element
|
|
104
|
+
|
|
105
|
+
* If the maximum element of a given degree sequence is `0`, then one can
|
|
106
|
+
remove it to reduce the sequence, following Havel and Hakimi's
|
|
107
|
+
rule. Conversely, if the maximum element of the (current) sequence is
|
|
108
|
+
`0`, then one can always extend it by adding a new element of degree
|
|
109
|
+
`0` to the sequence.
|
|
110
|
+
|
|
111
|
+
.. MATH::
|
|
112
|
+
|
|
113
|
+
0, 0, 0 \xrightarrow{Extension} {\bf 0}, 0, 0, 0 \xrightarrow{Extension}
|
|
114
|
+
{\bf 0}, 0, 0, ..., 0, 0, 0 \xrightarrow{Reduction} 0, 0, 0, 0
|
|
115
|
+
\xrightarrow{Reduction} 0, 0, 0
|
|
116
|
+
|
|
117
|
+
* If there are at least `\Delta+1` elements of (maximum) degree `\Delta`
|
|
118
|
+
in a given degree sequence, then one can reduce it by removing a
|
|
119
|
+
vertex of degree `\Delta` and decreasing the values of `\Delta`
|
|
120
|
+
elements of value `\Delta` to `\Delta-1`. Conversely, if the maximum
|
|
121
|
+
element of the (current) sequence is `d>0`, then one can add a new
|
|
122
|
+
element of degree `d` to the sequence if it can be linked to `d`
|
|
123
|
+
elements of (current) degree `d-1`. Those `d` vertices of degree `d-1`
|
|
124
|
+
hence become vertices of degree `d`, and so `d` elements of degree
|
|
125
|
+
`d-1` are removed from the sequence while `d+1` elements of degree `d`
|
|
126
|
+
are added to it.
|
|
127
|
+
|
|
128
|
+
.. MATH::
|
|
129
|
+
|
|
130
|
+
3, 2, 2, 2, 1 \xrightarrow{Extension} {\bf 3}, 3, (2+1), (2+1), (2+1), 1
|
|
131
|
+
= {\bf 3}, 3, 3, 3, 3, 1 \xrightarrow{Reduction} 3, 2, 2, 2, 1
|
|
132
|
+
|
|
133
|
+
* Extension of a degree sequence that changes the value of the maximum
|
|
134
|
+
element:
|
|
135
|
+
|
|
136
|
+
* In the general case, i.e. when the number of elements of value
|
|
137
|
+
`\Delta,\Delta-1` is small compared to `\Delta` (i.e. the maximum
|
|
138
|
+
element of a given degree sequence), reducing a sequence strictly
|
|
139
|
+
decreases the value of the maximum element. According to Havel and
|
|
140
|
+
Hakimi's characterization there is only **one** way to reduce a
|
|
141
|
+
sequence, but reversing this operation is more complicated than in the
|
|
142
|
+
previous cases. Indeed, the following extensions are perfectly valid
|
|
143
|
+
according to the reduction rule.
|
|
144
|
+
|
|
145
|
+
.. MATH::
|
|
146
|
+
|
|
147
|
+
2,1,1,0,0\xrightarrow{Extension} {\bf 3}, (2+1), (1+1), (1+1), 0, 0
|
|
148
|
+
= 3, 3, 2, 2, 0, 0 \xrightarrow{Reduction} 2, 1, 1, 0, 0\\
|
|
149
|
+
2,1,1,0,0\xrightarrow{Extension} {\bf 3}, (2+1), (1+1), 1, (0+1), 0
|
|
150
|
+
= 3, 3, 2, 1, 1, 0 \xrightarrow{Reduction} 2, 1, 1, 0, 0\\
|
|
151
|
+
2,1,1,0,0\xrightarrow{Extension} {\bf 3}, (2+1), 1, 1, (0+1), (0+1)
|
|
152
|
+
= 3, 3, 1, 1, 1, 1 \xrightarrow{Reduction} 2, 1, 1, 0, 0\\
|
|
153
|
+
...
|
|
154
|
+
|
|
155
|
+
In order to extend a current degree sequence while strictly increasing
|
|
156
|
+
its maximum degree, it is equivalent to pick a set `I` of elements of
|
|
157
|
+
the degree sequence with `|I|>\Delta` in such a way that the
|
|
158
|
+
`(d_i+1)_{i\in I}` are the `|I|` maximum elements of the sequence
|
|
159
|
+
`(d_i+\genfrac{}{}{0pt}{}{1\text{ if }i\in I}{0\text{ if }i\not \in
|
|
160
|
+
I})_{1\leq i \leq n}`, and to add to this new sequence an element of
|
|
161
|
+
value `|I|`. The non-increasing sequence containing the elements `|I|`
|
|
162
|
+
and `(d_i+\genfrac{}{}{0pt}{}{1\text{ if }i\in I}{0\text{ if }i\not
|
|
163
|
+
\in I})_{1\leq i \leq n}` can be reduced to `(d_i)_{1\leq i \leq n}`
|
|
164
|
+
by Havel and Hakimi's rule.
|
|
165
|
+
|
|
166
|
+
.. MATH::
|
|
167
|
+
|
|
168
|
+
... 1, 1, 2, {\bf 2}, {\bf 2}, 2, 2, 3, 3, \underline{3}, {\bf 3},
|
|
169
|
+
{\bf 3}, {\bf 4}, {\bf 6}, ... \xrightarrow{Extension} ... 1, 1,
|
|
170
|
+
2, 2, 2, 3, 3, \underline{3}, {\bf 3}, {\bf 3}, {\bf 4}, {\bf 4},
|
|
171
|
+
{\bf 5}, {\bf 7}, ...
|
|
172
|
+
|
|
173
|
+
The number of possible sets `I` having this property (i.e. the number
|
|
174
|
+
of possible extensions of a sequence) is smaller than it
|
|
175
|
+
seems. Indeed, by definition, if `j\not \in I` then for all `i\in I`
|
|
176
|
+
the inequality `d_j\leq d_i+1` holds. Hence, each set `I` is entirely
|
|
177
|
+
determined by the largest element `d_k` of the sequence that it does
|
|
178
|
+
**not** contain (hence `I` contains `\{1,...,k-1\}`), and by the
|
|
179
|
+
cardinalities of `\{i\in I:d_i= d_k\}` and `\{i\in I:d_i= d_k-1\}`.
|
|
180
|
+
|
|
181
|
+
.. MATH::
|
|
182
|
+
|
|
183
|
+
I = \{i \in I : d_i= d_k \} \cup \{i \in I : d_i= d_k-1 \}
|
|
184
|
+
\cup \{i : d_i> d_k \}.
|
|
185
|
+
|
|
186
|
+
The number of possible extensions is hence at most cubic, and is
|
|
187
|
+
easily enumerated.
|
|
188
|
+
|
|
189
|
+
About the implementation
|
|
190
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
191
|
+
|
|
192
|
+
In the actual implementation of the enumeration algorithm, the degree sequence
|
|
193
|
+
is stored differently for reasons of efficiency.
|
|
194
|
+
|
|
195
|
+
Indeed, when enumerating all the degree sequences of length `n`, Sage first
|
|
196
|
+
allocates an array ``seq`` of `n+1` integers where ``seq[i]`` is the number of
|
|
197
|
+
elements of value ``i`` in the current sequence. Obviously, ``seq[n]=0`` holds
|
|
198
|
+
in permanence : it is useful to allocate a larger array than necessary to
|
|
199
|
+
simplify the code. The ``seq`` array is a global variable.
|
|
200
|
+
|
|
201
|
+
The recursive function ``enum(depth, maximum)`` is the one building the list of
|
|
202
|
+
sequences. It builds the list of degree sequences of length `n` which *extend*
|
|
203
|
+
the sequence currently stored in ``seq[0]...seq[depth-1]``. When it is called,
|
|
204
|
+
``maximum`` must be set to the maximum value of an element in the partial
|
|
205
|
+
sequence ``seq[0]...seq[depth-1]``.
|
|
206
|
+
|
|
207
|
+
If during its run the function ``enum`` heavily works on the content of
|
|
208
|
+
the ``seq`` array, the value of ``seq`` is the **same** before and after
|
|
209
|
+
the run of ``enum``.
|
|
210
|
+
|
|
211
|
+
**Extending the current partial sequence**
|
|
212
|
+
|
|
213
|
+
The two cases for which the maximum degree of the partial sequence does not
|
|
214
|
+
change are easy to detect. It is (slightly) harder to enumerate all the sets
|
|
215
|
+
`I` corresponding to possible extensions of the partial sequence. As said
|
|
216
|
+
previously, to each set `I` one can associate an integer ``current_box`` such
|
|
217
|
+
that `I` contains all the `i` satisfying `d_i>current\_box`. The variable
|
|
218
|
+
``taken`` represents the number of all such elements `i`, so that when
|
|
219
|
+
enumerating all possible sets `I` in the algorithm we have the equality
|
|
220
|
+
|
|
221
|
+
.. MATH::
|
|
222
|
+
|
|
223
|
+
I = \text{taken }+\text{ number of elements of value }current\_box+
|
|
224
|
+
\text{ number of elements of value }current\_box-1.
|
|
225
|
+
|
|
226
|
+
REFERENCES:
|
|
227
|
+
|
|
228
|
+
- [RCES1994]_
|
|
229
|
+
|
|
230
|
+
AUTHORS:
|
|
231
|
+
|
|
232
|
+
- Nathann Cohen
|
|
233
|
+
|
|
234
|
+
TESTS:
|
|
235
|
+
|
|
236
|
+
The sequences produced by random graphs *are* degree sequences::
|
|
237
|
+
|
|
238
|
+
sage: n = 30
|
|
239
|
+
sage: DS = DegreeSequences(30)
|
|
240
|
+
sage: for i in range(10): # needs networkx sage.graphs
|
|
241
|
+
....: g = graphs.RandomGNP(n,.2)
|
|
242
|
+
....: if not g.degree_sequence() in DS:
|
|
243
|
+
....: print("Something is very wrong !")
|
|
244
|
+
|
|
245
|
+
Checking that we indeed enumerate *all* the degree sequences for `n=5`::
|
|
246
|
+
|
|
247
|
+
sage: ds1 = Set([tuple(g.degree_sequence()) for g in graphs(5)]) # needs nauty sage.graphs
|
|
248
|
+
sage: ds2 = Set(map(tuple,list(DegreeSequences(5))))
|
|
249
|
+
sage: ds1 == ds2 # needs nauty sage.graphs
|
|
250
|
+
True
|
|
251
|
+
|
|
252
|
+
Checking the consistency of enumeration and test::
|
|
253
|
+
|
|
254
|
+
sage: DS = DegreeSequences(6)
|
|
255
|
+
sage: all(seq in DS for seq in DS)
|
|
256
|
+
True
|
|
257
|
+
|
|
258
|
+
.. WARNING::
|
|
259
|
+
|
|
260
|
+
For the moment, iterating over all degree sequences involves building the
|
|
261
|
+
list of them first, then iterate on this list. This is obviously bad,
|
|
262
|
+
as it requires uselessly a **lot** of memory for large values of `n`.
|
|
263
|
+
|
|
264
|
+
This should be changed. Updating the code does not require more
|
|
265
|
+
than a couple of minutes.
|
|
266
|
+
"""
|
|
267
|
+
|
|
268
|
+
# ****************************************************************************
|
|
269
|
+
# Copyright (C) 2011 Nathann Cohen <nathann.cohen@gmail.com>
|
|
270
|
+
#
|
|
271
|
+
# This program is free software: you can redistribute it and/or modify
|
|
272
|
+
# it under the terms of the GNU General Public License as published by
|
|
273
|
+
# the Free Software Foundation, either version 2 of the License, or
|
|
274
|
+
# (at your option) any later version.
|
|
275
|
+
# https://www.gnu.org/licenses/
|
|
276
|
+
# ****************************************************************************
|
|
277
|
+
|
|
278
|
+
from cysignals.memory cimport check_calloc, sig_free
|
|
279
|
+
from cysignals.signals cimport sig_on, sig_off
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
cdef unsigned char * seq
|
|
283
|
+
cdef list sequences
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
class DegreeSequences:
|
|
287
|
+
|
|
288
|
+
def __init__(self, n):
|
|
289
|
+
r"""
|
|
290
|
+
Degree Sequences.
|
|
291
|
+
|
|
292
|
+
An instance of this class represents the degree sequences of graphs on a
|
|
293
|
+
given number `n` of vertices. It can be used to list and count them, as
|
|
294
|
+
well as to test whether a sequence is a degree sequence. For more
|
|
295
|
+
information, please refer to the documentation of the
|
|
296
|
+
:mod:`DegreeSequence<sage.combinat.degree_sequences>` module.
|
|
297
|
+
|
|
298
|
+
EXAMPLES::
|
|
299
|
+
|
|
300
|
+
sage: DegreeSequences(8)
|
|
301
|
+
Degree sequences on 8 elements
|
|
302
|
+
sage: [3,3,2,2,2,2,2,2] in DegreeSequences(8)
|
|
303
|
+
True
|
|
304
|
+
|
|
305
|
+
TESTS:
|
|
306
|
+
|
|
307
|
+
:issue:`21824`::
|
|
308
|
+
|
|
309
|
+
sage: DegreeSequences(-1)
|
|
310
|
+
Traceback (most recent call last):
|
|
311
|
+
...
|
|
312
|
+
ValueError: the input parameter must be >= 0
|
|
313
|
+
"""
|
|
314
|
+
if n < 0:
|
|
315
|
+
raise ValueError("the input parameter must be >= 0")
|
|
316
|
+
self._n = n
|
|
317
|
+
|
|
318
|
+
def __contains__(self, seq):
|
|
319
|
+
"""
|
|
320
|
+
Check whether a given integer sequence is the degree sequence
|
|
321
|
+
of a graph on `n` elements.
|
|
322
|
+
|
|
323
|
+
EXAMPLES::
|
|
324
|
+
|
|
325
|
+
sage: [3,3,2,2,2,2,2,2] in DegreeSequences(8)
|
|
326
|
+
True
|
|
327
|
+
|
|
328
|
+
TESTS:
|
|
329
|
+
|
|
330
|
+
:issue:`15503`::
|
|
331
|
+
|
|
332
|
+
sage: [2,2,2,2,1,1,1] in DegreeSequences(7)
|
|
333
|
+
False
|
|
334
|
+
|
|
335
|
+
:issue:`21824`::
|
|
336
|
+
|
|
337
|
+
sage: [d for d in DegreeSequences(0)]
|
|
338
|
+
[[]]
|
|
339
|
+
sage: [d for d in DegreeSequences(1)]
|
|
340
|
+
[[0]]
|
|
341
|
+
sage: [d for d in DegreeSequences(3)]
|
|
342
|
+
[[0, 0, 0], [1, 1, 0], [2, 1, 1], [2, 2, 2]]
|
|
343
|
+
sage: [d for d in DegreeSequences(1)]
|
|
344
|
+
[[0]]
|
|
345
|
+
"""
|
|
346
|
+
cdef int n = self._n
|
|
347
|
+
if len(seq) != n:
|
|
348
|
+
return False
|
|
349
|
+
|
|
350
|
+
# Is the sum even ?
|
|
351
|
+
if sum(seq) % 2:
|
|
352
|
+
return False
|
|
353
|
+
|
|
354
|
+
# Partial represents the left side of Erdos and Gallai's inequality,
|
|
355
|
+
# i.e. the sum of the i first integers.
|
|
356
|
+
cdef int partial = 0
|
|
357
|
+
cdef int i, d, dd, right
|
|
358
|
+
|
|
359
|
+
# Temporary variable to ensure that the sequence is indeed
|
|
360
|
+
# non-increasing
|
|
361
|
+
cdef int prev = n - 1
|
|
362
|
+
|
|
363
|
+
for i, d in enumerate(seq):
|
|
364
|
+
|
|
365
|
+
# Non-increasing ?
|
|
366
|
+
if d > prev:
|
|
367
|
+
return False
|
|
368
|
+
else:
|
|
369
|
+
prev = d
|
|
370
|
+
|
|
371
|
+
# Updating the partial sum
|
|
372
|
+
partial += d
|
|
373
|
+
|
|
374
|
+
# Evaluating the right hand side
|
|
375
|
+
right = i * (i + 1)
|
|
376
|
+
for dd in seq[i + 1:]:
|
|
377
|
+
right += min(dd, i + 1)
|
|
378
|
+
|
|
379
|
+
# Comparing the two
|
|
380
|
+
if partial > right:
|
|
381
|
+
return False
|
|
382
|
+
|
|
383
|
+
return True
|
|
384
|
+
|
|
385
|
+
def __repr__(self):
|
|
386
|
+
"""
|
|
387
|
+
Representing the element.
|
|
388
|
+
|
|
389
|
+
TESTS::
|
|
390
|
+
|
|
391
|
+
sage: DegreeSequences(6)
|
|
392
|
+
Degree sequences on 6 elements
|
|
393
|
+
"""
|
|
394
|
+
return "Degree sequences on "+str(self._n)+" elements"
|
|
395
|
+
|
|
396
|
+
def __iter__(self):
|
|
397
|
+
"""
|
|
398
|
+
Iterate over all the degree sequences.
|
|
399
|
+
|
|
400
|
+
TODO: THIS SHOULD BE UPDATED AS SOON AS THE YIELD KEYWORD APPEARS IN
|
|
401
|
+
CYTHON. See comment in the class' documentation.
|
|
402
|
+
|
|
403
|
+
EXAMPLES::
|
|
404
|
+
|
|
405
|
+
sage: DS = DegreeSequences(6)
|
|
406
|
+
sage: all(seq in DS for seq in DS)
|
|
407
|
+
True
|
|
408
|
+
"""
|
|
409
|
+
yield from init(self._n)
|
|
410
|
+
|
|
411
|
+
def __dealloc__():
|
|
412
|
+
"""
|
|
413
|
+
Freeing the memory
|
|
414
|
+
"""
|
|
415
|
+
sig_free(seq)
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
cdef init(int n):
|
|
419
|
+
"""
|
|
420
|
+
Initialize the memory and starts the enumeration algorithm.
|
|
421
|
+
"""
|
|
422
|
+
global seq
|
|
423
|
+
global N
|
|
424
|
+
global sequences
|
|
425
|
+
|
|
426
|
+
if n == 0:
|
|
427
|
+
return [[]]
|
|
428
|
+
elif n == 1:
|
|
429
|
+
return [[0]]
|
|
430
|
+
|
|
431
|
+
seq = <unsigned char *>check_calloc(n + 1, sizeof(unsigned char))
|
|
432
|
+
|
|
433
|
+
# We begin with one vertex of degree 0
|
|
434
|
+
seq[0] = 1
|
|
435
|
+
|
|
436
|
+
N = n
|
|
437
|
+
sequences = []
|
|
438
|
+
enum(1, 0)
|
|
439
|
+
sig_free(seq)
|
|
440
|
+
return sequences
|
|
441
|
+
|
|
442
|
+
cdef inline add_seq():
|
|
443
|
+
"""
|
|
444
|
+
This function is called whenever a sequence is found.
|
|
445
|
+
|
|
446
|
+
Build the degree sequence corresponding to the current state of the
|
|
447
|
+
algorithm and adds it to the sequences list.
|
|
448
|
+
"""
|
|
449
|
+
global sequences
|
|
450
|
+
global N
|
|
451
|
+
global seq
|
|
452
|
+
|
|
453
|
+
cdef list s = []
|
|
454
|
+
cdef int i, j
|
|
455
|
+
|
|
456
|
+
for N > i >= 0:
|
|
457
|
+
for 0 <= j < seq[i]:
|
|
458
|
+
s.append(i)
|
|
459
|
+
|
|
460
|
+
sequences.append(s)
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
cdef void enum(int k, int M) noexcept:
|
|
464
|
+
r"""
|
|
465
|
+
Main function; for an explanation of the algorithm please refer to the
|
|
466
|
+
:mod:`sage.combinat.degree_sequences` documentation.
|
|
467
|
+
|
|
468
|
+
INPUT:
|
|
469
|
+
|
|
470
|
+
- ``k`` -- depth of the partial degree sequence
|
|
471
|
+
- ``M`` -- value of a maximum element in the partial degree sequence
|
|
472
|
+
"""
|
|
473
|
+
cdef int i, j
|
|
474
|
+
global seq
|
|
475
|
+
cdef int taken = 0
|
|
476
|
+
cdef int current_box
|
|
477
|
+
cdef int n_current_box
|
|
478
|
+
cdef int n_previous_box
|
|
479
|
+
cdef int new_vertex
|
|
480
|
+
|
|
481
|
+
# Have we found a new degree sequence ? End of recursion !
|
|
482
|
+
if k == N:
|
|
483
|
+
add_seq()
|
|
484
|
+
return
|
|
485
|
+
|
|
486
|
+
sig_on()
|
|
487
|
+
|
|
488
|
+
#############################################
|
|
489
|
+
# Creating vertices of Vertices of degree M #
|
|
490
|
+
#############################################
|
|
491
|
+
|
|
492
|
+
# If 0 is the current maximum degree, we can always extend the degree
|
|
493
|
+
# sequence with another 0
|
|
494
|
+
if M == 0:
|
|
495
|
+
|
|
496
|
+
seq[0] += 1
|
|
497
|
+
enum(k + 1, M)
|
|
498
|
+
seq[0] -= 1
|
|
499
|
+
|
|
500
|
+
# We need not automatically increase the degree at each step. In this case,
|
|
501
|
+
# we have no other choice but to link the new vertex of degree M to vertices
|
|
502
|
+
# of degree M-1, which will become vertices of degree M too.
|
|
503
|
+
elif seq[M - 1] >= M:
|
|
504
|
+
|
|
505
|
+
seq[M] += M + 1
|
|
506
|
+
seq[M - 1] -= M
|
|
507
|
+
|
|
508
|
+
enum(k + 1, M)
|
|
509
|
+
|
|
510
|
+
seq[M] -= M + 1
|
|
511
|
+
seq[M - 1] += M
|
|
512
|
+
|
|
513
|
+
###############################################
|
|
514
|
+
# Creating vertices of Vertices of degree > M #
|
|
515
|
+
###############################################
|
|
516
|
+
|
|
517
|
+
for M >= current_box > 0:
|
|
518
|
+
|
|
519
|
+
# If there is not enough vertices in the boxes available
|
|
520
|
+
if taken + (seq[current_box] - 1) + seq[current_box-1] <= M:
|
|
521
|
+
taken += seq[current_box]
|
|
522
|
+
seq[current_box+1] += seq[current_box]
|
|
523
|
+
seq[current_box] = 0
|
|
524
|
+
continue
|
|
525
|
+
|
|
526
|
+
# The degree of the new vertex will be taken + i + j where:
|
|
527
|
+
#
|
|
528
|
+
# * i is the number of vertices taken in the *current* box
|
|
529
|
+
# * j the number of vertices taken in the *previous* one
|
|
530
|
+
|
|
531
|
+
n_current_box = seq[current_box]
|
|
532
|
+
n_previous_box = seq[current_box-1]
|
|
533
|
+
|
|
534
|
+
# Note to self, and others:
|
|
535
|
+
#
|
|
536
|
+
# In the following lines, there are many incrementation/decrementation
|
|
537
|
+
# that *may* be replaced by only +1 and -1 and save some
|
|
538
|
+
# instructions. This would involve adding several "if", and I feared it
|
|
539
|
+
# would make the code even uglier. If you are willing to give it a try,
|
|
540
|
+
# **please check the results** ! It is trickier that it seems ! Even
|
|
541
|
+
# changing the lower bounds in the for loops would require tests
|
|
542
|
+
# afterwards.
|
|
543
|
+
|
|
544
|
+
for max(0, (M+1)-n_previous_box-taken) <= i < n_current_box:
|
|
545
|
+
seq[current_box] -= i
|
|
546
|
+
seq[current_box+1] += i
|
|
547
|
+
|
|
548
|
+
for max(0, ((M+1)-taken-i)) <= j <= n_previous_box:
|
|
549
|
+
seq[current_box-1] -= j
|
|
550
|
+
seq[current_box] += j
|
|
551
|
+
|
|
552
|
+
new_vertex = taken + i + j
|
|
553
|
+
seq[new_vertex] += 1
|
|
554
|
+
enum(k+1, new_vertex)
|
|
555
|
+
seq[new_vertex] -= 1
|
|
556
|
+
|
|
557
|
+
seq[current_box-1] += j
|
|
558
|
+
seq[current_box] -= j
|
|
559
|
+
|
|
560
|
+
seq[current_box] += i
|
|
561
|
+
seq[current_box+1] -= i
|
|
562
|
+
|
|
563
|
+
taken += n_current_box
|
|
564
|
+
seq[current_box] = 0
|
|
565
|
+
seq[current_box+1] += n_current_box
|
|
566
|
+
|
|
567
|
+
# Corner case
|
|
568
|
+
#
|
|
569
|
+
# Now current_box = 0. All the vertices of nonzero degree are taken, we just
|
|
570
|
+
# want to know how many vertices of degree 0 will be neighbors of the new
|
|
571
|
+
# vertex.
|
|
572
|
+
for max(0, ((M+1)-taken)) <= i <= seq[0]:
|
|
573
|
+
|
|
574
|
+
seq[1] += i
|
|
575
|
+
seq[0] -= i
|
|
576
|
+
seq[taken+i] += 1
|
|
577
|
+
|
|
578
|
+
enum(k+1, taken+i)
|
|
579
|
+
|
|
580
|
+
seq[taken+i] -= 1
|
|
581
|
+
seq[1] -= i
|
|
582
|
+
seq[0] += i
|
|
583
|
+
|
|
584
|
+
# Shift everything back to normal ! ( cell N is always equal to 0)
|
|
585
|
+
for 1 <= i < N:
|
|
586
|
+
seq[i] = seq[i+1]
|
|
587
|
+
|
|
588
|
+
sig_off()
|