# Questions tagged [combinatorics]

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

522 questions
Filter by
Sorted by
Tagged with
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....
• 19.7k
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 ...
• 101
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 ...
• 7,843
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$ ...
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}, {...
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 ...
• 243
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 ...
• 65
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’ ...
• 3
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 ...
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 ...
• 159
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 ...
• 1,541
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 ...
• 65
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 : ...
• 1,343
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 ...
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: ...
• 189
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 ...
• 837
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 ...
• 1,725
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 ...
• 1,725
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 ...
• 1,541
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 ...
• 1,725
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 ...
• 1,725
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,725
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 ...
• 249
1 vote
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 ...
• 47k
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,725
1 vote
128 views

• 105
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,059
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$...
• 476
1 vote
71 views

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 ...
• 143
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, ...
• 123
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,059
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 ...
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 ...
• 63
1 vote
207 views

### Arrange 1-n^2 in n×n grid satisfy products of rows equal to products columns

For which $n\in\mathbb{N}$ is it possible to arrange $\{1,…,n^2\}$ in an $n\times n$ grid so that the set of products of columns equals the set of products of rows? I can find solution for $3\times 3$ ...
• 5,652
78 views

### Can FindMinimumCostFlow be trusted?

So, I recently began to use graphs algorithms in Mathematica notebooks to solve an unbalanced assignment problem. After running the algorithm, I wanted to check that the total flow was equal to the ...
• 185
1 vote