COMBO
Kreher and Stinson Combinatorial Routines
COMBO
is a Python library which
includes routines for ranking, unranking, enumerating and
randomly selecting balanced sequences, cycles, graphs, Gray codes,
subsets, partitions, permutations, restricted growth functions,
Pruefer codes and trees.
Routines are available to count, list, rank and unrank such objects
-
BAL, balanced sequences;
-
CYCLE, permutations of the first N integers in cycle form;
-
GRAPH, graphs stored as a list of edges.
-
GRAY, Gray codes;
-
KNAPSACK, optimally filling a knapsack of given size using
a set of smaller objects;
-
KSUBSET, subsets of size exactly K from a set of N objects;
-
NPART, partitions of an integer having exactly N parts;
-
PART, partitions of an integer;
-
PERM, permutations of the first N integers in standard form;
-
PRUEFER, Pruefer codes;
-
RGF, restricted growth functions;
-
SETPART, partitions of a set;
-
SUBSET, subsets of a set of N objects;
-
TABLEAU, tableaus;
-
TREE, trees;
Some of these sets of objects can be ordered in several different
ways, and in some cases, a separate set of ranking, unranking, and
successor routines are available for the various orderings
(lexical, colexical, revolving door, Trotter-Johnson).
Kreher and Stinson provide C source-code for the routines,
as well as other information, at
their web site.
Licensing:
The computer code and data files described and made available on this web page
are distributed under
the GNU LGPL license.
Languages:
COMBO is available in
a C version and
a C++ version and
a FORTRAN90 version and
a MATLAB version and
a Python version.
Related Data and Programs:
MONOMIAL,
a Python library which
enumerates, lists, ranks, unranks and randomizes multivariate monomials
in a space of M dimensions, with total degree less than N,
equal to N, or lying within a given range.
PARTITION_PROBLEM,
a Python library which
seeks solutions of the partition problem, splitting a set of integers into
two subsets with equal sum.
POLYNOMIAL,
a Python library which
adds, multiplies, differentiates, evaluates and prints multivariate
polynomials in a space of M dimensions.
SUBSET,
a Python library which
generates, ranks and unranks various combinatorial objects.
SUBSET_SUM,
a Python library which
seeks solutions of the subset sum problem.
UNICYCLE,
a Python library which
considers permutations containing a single cycle, sometimes called
cyclic permutations.
Source Code:
-
backtrack.py,
supervises a backtrack search.
-
bal_seq_check.py,
checks a balanced sequence.
-
bal_seq_enum.py,
enumerates the balanced sequences.
-
bal_seq_rank.py,
ranks a balanced sequence.
-
bal_seq_successor.py,
returns the successor of a balanced sequence.
-
bal_seq_to_tableau.py,
converts a balanced sequence to a tableau.
-
bal_seq_unrank.py,
unranks a balanced sequence.
-
bell_numbers.py,
computes the Bell numbers.
-
bell_values.py,
returns some values of the Bell numbers.
-
cycle_check.py,
checks a permutation in cycle form.
-
cycle_to_perm.py,
converts a permutation from cycle to array form.
-
dist_enum.py,
enumerates the number of distributions of indistinguishable objects.
-
dist_next.py,
returns the next distribution of indistinguishable objects.
-
edge_check.py,
checks a graph described by an edge list.
-
edge_degree.py,
returns the degree of each node in a graph described by an edge list.
-
edge_enum.py,
enumerates the maximum number of edges in a graph with a given
number of nodes.
-
gamma_log_values.py,
returns selected values of the log(gamma) function;
-
gray_code_check.py,
checks a Gray code element.
-
gray_code_enum.py,
enumerates the Gray codes on N digits.
-
gray_code_rank.py,
computes the rank of a Gray code element.
-
gray_code_successor.py,
computes the binary reflected Gray code successor.
-
gray_code_unrank.py,
computes the Gray code element of given rank.
-
i4_choose.py,
computes the binomial coefficient C(N,K).
-
i4_factorial.py,
computes the factorial function.
-
i4_factorial_values.py,
returns some values of the factorial function.
-
i4_fall.py,
evaluates the falling factorial function.
-
i4_fall_values.py,
returns some values of the falling factorial function.
-
i4_huge.py,
returns a huge I4;
-
i4_uniform_ab.py,
returns a pseudorandom I4 in a given range;
-
i4mat_print.py,
prints an I4MAT.
-
i4mat_print_some.py,
prints some of an I4MAT.
-
i4vec_backtrack.py,
supervises a backtrack search for an I4VEC.
-
i4vec_dot_product.py,
computes the dot product of two I4VEC's.
-
i4vec_indicator1.py,
sets an I4VEC to the indicator vector.
-
i4vec_part1.py,
partitions an integer N into NPART parts.
-
i4vec_part2.py,
partitions an integer N into NPART nearly equal parts.
-
i4vec_print.py,
prints an I4VEC.
-
i4vec_reverse.py,
reverses the order of the entries of an I4VEC;
-
i4vec_search_binary_a.py,
searches the ascending sorted I4VEC for a value.
-
i4vec_search_binary_d.py,
searches the descending sorted I4VEC for a value.
-
i4vec_sort_insert_a.py,
uses an ascending insertion sort on an I4VEC.
-
i4vec_sort_insert_d.py,
uses a descending insertion sort on an I4VEC.
-
i4vec_transpose_print.py,
prints an I4VEC "transposed", that is, 5 entries to a line.
-
i4vec_uniform_ab.py,
returns a pseudorandom I4VEC in a given range;
-
knapsack_01.py,
solves the 0,1 knapsack problem.
-
knapsack_rational.py,
solves the rational knapsack problem.
-
knapsack_reorder.py,
reorders the knapsack data by "profit density".
-
ksubset_colex_check.py,
checks a K subset in colex form.
-
ksubset_colex_rank.py,
computes the colex rank of a K subset.
-
ksubset_colex_successor.py,
computes the K subset colex successor.
-
ksubset_colex_unrank.py,
computes the K subset of given colex rank.
-
ksubset_enum.py,
enumerates the K element subsets of an N set.
-
ksubset_lex_check.py,
checks a K subset in lex form.
-
ksubset_lex_rank.py,
computes the lexicographic rank of a K subset.
-
ksubset_lex_successor.py,
computes the K subset lexicographic successor.
-
ksubset_lex_unrank.py,
computes the K subset of given lexicographic rank.
-
ksubset_revdoor_rank.py,
computes the revolving door rank of a K subset.
-
ksubset_revdoor_successor.py,
computes the K subset revolving door successor.
-
ksubset_revdoor_unrank.py,
computes the K subset of given revolving door rank.
-
marriage.py,
finds a stable set of marriages for given preferences.
-
mountain.py,
enumerates the mountains.
-
npart_enum.py,
enumerates the number of partitions of N with NPART parts.
-
npart_rsf_lex_random.py,
returns a random RSF NPART partition.
-
npart_rsf_lex_rank.py,
computes the lex rank of an RSF NPART partition.
-
npart_rsf_lex_successor.py,
computes the RSF lex successor for NPART partitions.
-
npart_rsf_lex_unrank.py,
unranks an RSF NPART partition in the lex ordering.
-
npart_sf_lex_successor.py,
computes SF NPART partition.
-
npart_table.py,
tabulates the number of partitions of N having NPART parts.
-
part_enum.py,
enumerates the partitions of an integer.
-
part_rsf_check.py,
checks a reverse standard form partition of an integer.
-
part_sf_check.py,
checks a standard form partition of an integer.
-
part_sf_conjugate.py,
computes the conjugate of a partition.
-
part_sf_majorize.py,
determines if partition A majorizes partition B.
-
part_successor.py,
computes the lexicographic partition successor.
-
part_table.py,
tabulates the number of partitions of N.
-
partition_greedy.py,
attacks the partition problem with a greedy algorithm.
-
partn_enum.py,
enumerates the partitions of N with maximum element NMAX.
-
partn_sf_check.py,
checks an SF partition of an integer with largest entry NMAX.
-
partn_successor.py,
computes partitions whose largest part is NMAX.
-
perm_check.py,
checks that a vector represents a permutation.
-
perm_enum.py,
enumerates the permutations on N digits.
-
perm_inv.py,
computes the inverse of a permutation.
-
perm_lex_rank.py,
computes the lexicographic rank of a permutation.
-
perm_lex_successor.py,
computes the lexicographic permutation successor.
-
perm_lex_unrank.py,
computes the permutation of given lexicographic rank.
-
perm_mul.py,
computes the product of two permutations.
-
perm_parity.py,
computes the parity of a permutation.
-
perm_print.py,
prints a permutation.
-
perm_random.py,
returns a random permutation.
-
perm_tj_rank.py,
computes the Trotter-Johnson rank of a permutation.
-
perm_tj_successor.py,
computes the Trotter-Johnson permutation successor.
-
perm_tj_unrank.py,
computes the permutation of given Trotter-Johnson rank.
-
perm_to_cycle.py,
converts a permutation from array to cycle form.
-
pruefer_check.py,
checks a Pruefer code.
-
pruefer_enum.py,
enumerates the Pruefer codes on N-2 digits.
-
pruefer_rank.py,
ranks a Pruefer code.
-
pruefer_successor.py,
computes the lexical Pruefer sequence successor.
-
pruefer_to_tree.py,
converts a Pruefer code to a tree.
-
pruefer_unrank.py,
unranks a Pruefer code.
-
queens.py,
finds possible positions for the K-th nonattacking queen.
-
r8_choose.py,
computes the binomial coefficient C(N,K).
-
r8_gamma_log.py,
returns the logarithm of the gamma function.
-
r8vec_backtrack.py,
supervises a backtrack search for an R8VEC.
-
rgf_check.py,
checks a restricted growth function.
-
rgf_enum.py,
enumerates the restricted growth functions on M.
-
rgf_rank.py,
ranks a restricted growth function.
-
rgf_successor.py,
generates the next restricted growth function.
-
rgf_to_setpart.py,
converts a restricted growth function to a set partition.
-
rgf_unrank.py,
returns the restricted growth function of a given rank.
-
rgf_g_table.py,
tabulates the generalized restricted growth functions.
-
setpart_check.py,
checks a set partition.
-
setpart_enum.py,
enumerates the partitions of a set of M elements.
-
setpart_to_rgf.py,
converts a set partition to a restricted growth function.
-
stirling_numbers1.py,
computes the Stirling numbers of the first kind.
-
stirling_numbers2.py,
computes the Stirling numbers of the second kind.
-
subset_check.py,
checks a subset.
-
subset_colex_rank.py,
computes the colexicographic rank of a subset.
-
subset_colex_successor.py,
computes the subset colexicographic successor.
-
subset_colex_unrank.py,
computes the subset of given colexicographic rank.
-
subset_complement.py,
computes the complement of a set.
-
subset_distance.py,
computes the Hamming distance between two sets.
-
subset_enum.py,
enumerates the subsets of a set with N elements.
-
subset_intersect.py,
computes the intersection of two sets.
-
subset_lex_rank.py,
computes the rank of a given lexicographic subset.
-
subset_lex_successor.py,
computes the lexicographic successor of a subset.
-
subset_lex_unrank.py,
computes the subset of a given lexicographic rank.
-
subset_random.py,
returns a random subset of an N set.
-
subset_union.py,
computes the union of two sets.
-
subset_weight.py,
computes the Hamming weight of a set.
-
subset_xor.py,
computes the symmetric difference of two sets.
-
subsetsum_swap.py,
seeks a solution of the subset sum problem by swapping.
-
tableau_check.py,
checks a 2 by N tableau.
-
tableau_enum.py,
enumerates the 2 by N standard tableaus.
-
tableau_to_bal_seq.py,
converts a 2 by N tableau to a balanced sequence.
-
timestamp.py,
prints the current YMDHMS date as a timestamp.
-
tree_check.py,
checks a tree.
-
tree_enum.py,
enumerates the trees on N nodes.
-
tree_rank.py,
ranks a tree.
-
tree_successor.py,
returns the successor of a tree.
-
tree_to_pruefer.py,
converts a tree to a Pruefer code.
-
tree_unrank.py,
unranks a tree.
Examples and Tests:
You can go up one level to
the Python source codes.
Last revised on 01 January 2016.
<%-- John Burkardt -->