Skip to main content

Questions tagged [combinatorics]

Questions on the use of Mathematica in combinatorics, including the Combinatorica add-on package.

Filter by
Sorted by
Tagged with
17 votes
3 answers
1k views

Generating Gelfand-Tsetlin patterns

I am doing some research on some combinatorial object called GT-patterns. They are generated from three parts of data. Two integer, partitions (sequences of weakly decreasing numbers), $\lambda = \...
5 votes
1 answer
155 views

Find permutation that satisfies conditions

Suppose you what to find a permutation of integers {1, 2, ..., 13} that satisfy some rules. Rules can be found in variable rules....
6 votes
2 answers
268 views

Combine each element with all the others in sublists

Suppose that I have a list of numbers list = {{{1, 0}, {-1, 1}, {0, -1}}, {{-1, 0, 1}, {-1, 1, -1}, {-1, -1, 0}, {1, 1, 0}, {1, -1, 1}, {1, 0, -1}}} I would like ...
7 votes
3 answers
494 views

How can I make this code to count Hamiltonian paths faster?

I have this very basic code to count Hamiltonian paths in a graph: ...
6 votes
4 answers
302 views

Distribute arguments over a function in all ordered combinations

I'm looking for a function that can do this ...
2 votes
3 answers
113 views

Expanding integer compositions

Quick version: I would like Mathematica code that, for instance, turns {3,1,2} into {3,3,3,1,2,2}. More formally, given positive integers $c_1, \ldots, c_t$ which sum to $n$, produce the length $n$ ...
6 votes
3 answers
291 views

Plot diagonal lattice path

I'd like to plot lattice paths like RUURUD where R is a step to the right, U is a step above ...
0 votes
0 answers
35 views

Writing list as disjoint union of input lists

Suppose I have two lists, s1={{1,2,3},{3,1,2},{3,1,2},{2,3,1},{3,2,1},{1,3,2}} and ...
12 votes
3 answers
451 views

Visualizing diagrams needed to compute $\operatorname{Tr}(A^3 (A^T)^3)$

I'm looking for help getting Mathematica code to construct diagrammatic expressions like the following, obtained by River Li as a way to compute $\operatorname{Tr}(A^2 (A^T)^2)$ for $d\times d$ matrix ...
6 votes
3 answers
93 views

How can I convert sequences to sharings and vice versa?

Given positive integers $k,n$, a $k$-sequence of $I_n$ is a list of $k$ not necessarily distinct elements of $\{1,\dots, n\}$. And an $n$-sharing of $I_k$ is a list of $n$ possibly empty, disjoint ...
2 votes
1 answer
161 views

How to implement the formula for the number of undirected $k$-cycles in a graph $G$?

This Wolfram MathWorld page said that, Giscard et al. "A General Purpose Algorithm for Counting Simple Cycles and Simple Paths of Any Length." 16 Dec 2016. gave the formula for the number of ...
7 votes
10 answers
540 views

Count number of balls in each bin, given a two-element sequence of balls and bins

If I have a list: {ball,ball,BINDIVIDER,ball,ball,ball,BINDIVIDER,BINDIVIDER,ball,BINDIVIDER,ball} The balls and bins can be in any permutation. Then, the ...
4 votes
3 answers
117 views

How can I construct an equivalence relation in the form of a 0-1 matrix from a set partition?

I have a partition of a set {1, 2, ..., n}. I would like to construct the equivalence relation that corresponds to the set partition in the form of an $n \times n$ ...
3 votes
4 answers
271 views

Tuples of elements from list excluding anything with repeated values

What I would like to do is the following. For a given list of elements; say (0,1,2,3,4) I would like to obtain all possible combinations of five, but not the ones with ANY repeated values. That is I ...
2 votes
3 answers
102 views

I'm tired trying to get subsets

t={{a,b},{},{},{},{a},{a,b},{},{a,b,c},{},{b}} s={{},{a,b,c},{a,b}} Thread[Subset[t,s]] I'm tired of trying to calculate: {a,b} [which is the intersection [{a,b}, {...
7 votes
3 answers
242 views

Insert abs into two adjacent terms of the expression

Give an expression expr = a - b - c - d - e; I need to add abs between adjacent letters, the desired result is ...
2 votes
2 answers
303 views

How to generate a list of Langford pairings?

I am wondering how to make a function that makes a list of Langford pairings named LangfordPairings that takes an integer n as output and if Langford pairings exist for that number, they output the ...
0 votes
0 answers
26 views

Nonintersecting lattice paths with given start and endpoints

A prominent topic in combinatorics is the enumeration of nonintersecting lattice paths subject to certain conditions. My goal is fairly simple: given starting points $(1,1), (2,1), \ldots, (k,1)$ and ...
0 votes
1 answer
152 views

PartitionsP for non-integer arguments [closed]

Is there a reason why the function PartitionsP[] does not return anything for non-integer arguments, although there is a way to calculate using Rademacher’s ‘exact’ ...
2 votes
1 answer
111 views

Efficiently Finding Weighted Integer Partitions

Suppose we have some list of natural numbers $\{ 1, 2, \dots, N \}$ and each natural number $i$ has a 'weight' $w_i$. I would like to generate the all the integer partitions which satisfy the ...
11 votes
7 answers
1k views

Sierpinski carpet with GraphData

Is this graph in the list among the so-called "standard" structures used in GraphData? However, I have not found yet anything like "Carpet" or "Sponge" in the list ...
2 votes
0 answers
47 views

NextSetPartition

I'm looking for a function similar to the one in the question below, but for the more general problem of set partitions without restricting the set size. NextKSizePartition, or how to partition a set ...
11 votes
2 answers
473 views

Can you give a faster implementation with Mathematica for these q-analog functions?

Now(2023), Mathematica has some QFunctions for q-anlaog. See Official Documentation. e.g.: QPochhammer QFactorial ...
3 votes
2 answers
129 views

Generating semistandard Young tableaux in Mathematica?

The Combinatorica package is able to generate standard Young tableau via the command Tableaux. But is there any functionality for generating semistandard Young ...
0 votes
0 answers
50 views

Convex hull aborts kernels (reproducible)

11.0.0 for Microsoft Windows (64-bit) (July 28, 2016) ReleaseID -> "11.0.0.0 (5570737, 2016072801) a set of 32 points : ...
11 votes
8 answers
1k views

Transform a number to a factorial

I came across the need to transform a number into a factorial n, with positive integer n. I have searched in the MMA information but I can't find anything like that. I imagine an input, which verifies ...
2 votes
3 answers
259 views

How can I optimise the creation of subsets?

I have a list of 21 elements from which I have obtained possible combinations of minimum 3 and up to 10 elements using the Subsets function as follows: ...
8 votes
2 answers
635 views

Better code for Ramsey partitions

Ramsey partitions for parameters $a$ and $b$ are certain integer partition of $a+b$ developed by McAvaney, Robertson, and Webb (Combinatorica 1992) for applications in fair division problems where two ...
10 votes
3 answers
1k views

Solving a rotating combination lock puzzle

The following puzzle appears in The House of da Vinci II and I thought it might be interesting to tackle in Mathematica: There are numbers marked on four rotating cylinders. These numbers must add up ...
3 votes
1 answer
163 views

How to make a function that returns all super distinct partitions?

I am working on distinct partitions. I recently created a function StrictIntegerPartitions. This is from the book Integer Partitions by George E. Andrews at Pennsylvania State University and Kimmo ...
0 votes
1 answer
51 views

Using UnrankPermutation with Maximize

I want to try and use Maximize with UnrankPermutation to find Costas Arrays (or as close as possible) for a given length l with first two elements l, 1. A permutation array that maximizes the number ...
9 votes
2 answers
528 views

Drawing Delannoy paths

I want to take the code for a Wolfram Demonstration for a Delannoy number and make a function that can return a list of Delannoy plots. The code is available from the download link. The demonstration ...
0 votes
2 answers
89 views

How to make a function that outputs a mesh region object or some other geometric object that represents a cake number?

The lazy caterer's sequence, more formally known as the central polygonal numbers, describes the maximum number of pieces of a disk (a pancake or pizza is usually used to describe the situation) that ...
3 votes
1 answer
163 views

Mathematica code for q-Stirling numbers

In the paper [A new $q$-Analog of Stirling Numbers],(https://hal.archives-ouvertes.fr/hal-01372920/document)[PDF] J. Cigler defined $q$-Stirling numbers of the second kind as the following: He ...
1 vote
2 answers
877 views

Splitting a list into 2 sublists in all possible ways

I have a list and I want to split it into 2 sublists in all possible ways If S={1,2,3,4} I should get ...
8 votes
4 answers
744 views

Design a function that gives all strict partitions of an integer

A strict partition of an integer has all distinct parts. There are no duplicates like 1 in {5,3,1,1} for 10. All the parts are unique. Sylvester created a bijection between the partitions of an ...
1 vote
1 answer
255 views

Enumeration of a sequence involving closure operators

Let us call a collection $\mathcal{F} \subseteq \mathcal{P}(X)$ special if it satisfies the following two conditions: $\emptyset, X \in \mathcal{F}$ For all $U, V \in \mathcal{F}$, it holds that $U \...
4 votes
3 answers
174 views

Generating all complete pair-wise listing of a starting list

It might well turn out that this question has already been asked; my problem is that I don't know how to describe it succinctly enough to search. I have a list of 12 elements. If I take 2 elements ...
0 votes
1 answer
146 views

How to calculate the number of partial derangements of a multiset in Mathematica?

I have found some helpful information on enumerating derangements at https://math.stackexchange.com/questions/4645664/the-number-of-partial-derangements-of-a-52-card-deck-ignoring-suits, https://sites....
1 vote
0 answers
41 views

Sequence reconstruction from ordered subsamples

Given a sequence (we'll assume of integers) like seq = {1, 0, 0, 1, 2, 0, 1} I can take a random permutation ...
5 votes
1 answer
421 views

Enumeration of a certain sequence I

Lets denote by $a(n)$ the number of families $\mathcal{F} \subseteq \mathcal{P}(X)$ on a finite set $X$ with $n$ elements satisfying: $\emptyset, X \in \mathcal{F}$ For all $U, V \in \mathcal{F}$ it ...
3 votes
1 answer
264 views

Enumeration of a certain sequence III

Let’s call a collection $\mathcal{F} \subseteq \mathcal{P}(X)$ satisfying: $\emptyset, X \in \mathcal{F}$ For all $U, V \in \mathcal{F}$ it holds that $U \cap V \in \mathcal{F}$. special. We can ...
1 vote
1 answer
128 views

Fixing code for a combinatorics problem

The problem I am solving is: Determine all possible values of positive integer $n$, such that there are $n$ different $3$-element subsets $A_1,A_2,...,A_n$ of the set $\{1,2,...,n\}$, with $|A_i \cap ...
8 votes
2 answers
573 views

How can I correctly use LazySubsets from Wolfram's Lazy package?

I know that Subsets[list] gives the power set of list and Subsets[list,{k}] gives all subsets containing exactly $k$ elements. ...
2 votes
1 answer
235 views

Finding induced subgraphs that are also trees

Given a graph $G$ with $n$ vertices, I need to find a subgraph consisting of $m$ vertices $\{v_1,\ldots,v_m\}$, and the induced subgraph of this subgraph should also be a tree. For example, suppose $G$...
1 vote
1 answer
71 views

Additive graphs code

For $n\geq 1$ the fibonacci sum graph on the set $[n]=\{1,2,\ldots,n\}$ denoted by $G_n$, is the graph with vertex set $[n]$ and edge set $\{uv, u+v=F_i, \text{for some}\quad i\}$. I wrote the ...
2 votes
0 answers
113 views

Is FindShortestTour really exact? [closed]

I have read online that the FindShortestTour function on Mathematica uses the Concorde TSP solver, which is meant to provide exact solutions. However, I have been playing with this problem on my own, ...
4 votes
2 answers
246 views

How to find a Hamiltonian walk of a graph?

Edit: After John L.'s reminder, there is a specific term, namely "Hamiltonian walk" for my previous question. See How can we find a shortest closed walk passing through all vertices?. So I ...
2 votes
1 answer
109 views

Find all ways to split a list into k sublists (of different length)

I would like to write an efficient code for splitting a set into k disjoint subsets, whose union would be the input set. The input set is represented by sorted lists with no repetitions, and the ...
5 votes
4 answers
298 views

Efficient generation of n-bit base-m Gray code with adjacent bit changes

How can I generate n-bit base-m Gray code in Mathematica, where only 1 bit changes at a time and all possibilities are covered? I have been hitting my head against a metaphorical wall for a few hours ...

1
2 3 4 5
11