# Questions tagged [combinatorics]

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

125 questions
Filter by
Sorted by
Tagged with
309 views

### Stars and Bars representation

How can I visualise/represent "Stars and Bars" in Mathematica? Say I have $n$ balls and $k$ slots to fill (or not to fill) with balls, e.g. when $n=4$ and $k=4$, ...
• 1,273
1k views

### How to compute the automorphisms of graphs with multiple edges?

I try to compute the Automorphisms of graphs with multiple edges from its AdjacencyMatrix but failed. The following code shows ...
• 1,145
706 views

### Efficiently generating tuples with Outer

I'm trying to efficiently generate tuples of lists of objects that satisfy a given criterion. The similar questions that I have found on this website end up finding a specific workaround for the given ...
• 2,469
566 views

### How expand Binomial[n, k] for k >= 6? [closed]

Binomial[n, k] is converted to a polynomial only for k less than 6. ...
• 2,704
798 views

### Listing matrices up to symmetry

I am interested in the equivalence relation on N x N binary matrices, in which two matrices are equivalent if one can be obtained by rotating/reflecting the other. I would like to obtain a list ...
• 355
202 views

### Combinatorics: Placed errors

Consider a vector of length n where each element can take one of the values U, X, ...
• 73
524 views

### Combinatorica: Girth[] and FindCycle[] disagreement

Warning: run the following code in a fresh Mma session, as some symbols could be shadowed (depending on your Mma version) While trying to answer this question, I fell into the following: ...
• 115k
273 views

### How the solve the parameter of the conjugate permutations

As we know the definition of conjugate permutations is: $$\exists p \quad p^{-1} \alpha p=\beta$$ When I have an alpha=Cycles[{{1,4},{2,5,6,3}}] and a ...
• 26.3k
459 views

### Find position without iterating

The code below solves for the four value of $m_i$ for a given pair of $(N_m,M_m)$. where $$m_1+m_2+m_3+m_4 = M_m\\ |m_1|+|m_2|+|m_3|+|m_4| = N_m$$ Edit 2 New Sorting I have now realised that the ...
• 3,584
544 views

### Concise way to generate multiset lists

I wrote the following to generate a multiset with the same number of items over a fixed range: ConstantArray[#, 3]& /@ Range[9] // Flatten ...
• 4,048
253 views

### NextKSizePartition, or how to partition a set into subsets of size $k$ but incrementally

This question might seem very much like the linked one below but it differs in a very special way; Mr.Wizard suggested I start a new post: Partition a set into subsets of size $k$ What I want is to ...
• 637
642 views

• 1,485
1 vote
276 views

### How to generate the lists of $0 \leq m \leq X$ integer values so these values add up to $X$

This must be basic, but my Mathematica (and overall programming) skill level is too low to find a handy solution: I need to generate all possible lists of $m$ integers (I call these integers $x_i$'s, ...
179 views

### How to create all possible permutations? [closed]

there is a problem: I have 5 letters - a,b,c,d,e and 20 places. I have to use each letter at least once but no more than 10 times. So the result can look like {a,a,a,a,a,a,a,a,a,a,b,b,b,b,b,b,b,c,d,e},...
• 21
707 views

### How to enumerate all possible binary associations?

Suppose I have a list of symbols like: {a,b,c,d} I would like to enumerate all possible binary associations (combining symbols and/or sublists pairwise): ...
• 2,257
813 views

### Count number of sublists with a total not greater than a given max

Suppose I have a list of positive integers: data={1, 1, 2, 3, 3, 3, 5, 5, 5, 7, 7, 8, 8, 9, 10, 10, 12, 16, 23} I want to count the number of subsets up to ...
• 5,172
571 views

### When to use built-in Graph/GraphPlot vs. Combinatorica

What are the pros and cons of using built-in Graph/GraphPlot (and related) types vs. types in the Combinatorica package?
• 949
868 views

• 245
333 views

### How to efficiently compute all trees with n leaves and 2n-2 nodes

I would like to efficiently compute all trees with n leaves and 2n-2 nodes. This is equivalent to trees with n leaves where all interior (non-leaf) vertices are trivalent. The input should be the ...
285 views

### How to express permutation as the least number of exchanges

If there are grammatical or terminological errors in the following description, please help correct: In some problems, it is necessary to find out what minimum number of exchanges can change a list ...
861 views

### Duplicate Permutations with Tuples

Permutations without repetition (in Italian: simple dispositions) Permutations[{a, b, c, d}, {3}] or ...
• 4,422
101 views

### Splitting a set of integers over a set of bins

I have a problem that feels like it should be simple but I'm just drawing a blank on. I've got a set of integers, e.g. ...
• 46.6k
256 views

### Random filling of L-length line with l-length segments

I have discrete L-length line filled randomly with 2-length segments so its cover line with gaps 0 or 1. So we can describe cover configuration as sequence of gaps such as {0,0,1,0,1}. How I can ...
• 3,401
450 views

### How to efficiently find all combinations of the letters in an alphabet given a condition

Problem: I want to find all unique expressions with n number of terms that contain all the digits (or characters) in alphabet. ...
• 802
2k views

### Efficiently find all connected subgraphs

Is there a way to generate all the connected subgraphs of a graph in mathematica without going through all the subsets of the nodes and checking if the subgraph is connected (which will be O(2^N)*O(...
• 443
719 views

### How to define even permutations correctly?

I define even permutations as following, but there may be some error. I use it in two different way and get different output. ...
• 1,145
2k views

### How to implement Kemeny-Young method? (rank aggregation problem)

Prehistory I am trying to make some statistical analysis of some experimental data, arises from measurements made ​​on an ordinal scale. I faced with the problem of rank aggregation: to get from many &...
• 177
1k views

### How can I generate permutations of bit strings with repetition?

How can I write a function which has two parameters and it should generate combination of arbitrary range bits, for example: function[n, k], with ...
617 views

### Partition a range of integers into triples

Some time ago, I was asked to look at a simple to formulate puzzle. Consider the list of numbers {1,2, ..., 33}. Try to split this list in 11 triples, such that in ...
• 10.1k