Questions tagged [subset]

Questions on the usage of the Subsets command and related functionalities (Tuples, Permutations etc.), and on how to implement more efficient algorithms.

Filter by
Sorted by
Tagged with
3 votes
3 answers
199 views

Dropping list elements that are members of other lists [closed]

I have a set: $$A=\{\{1,2,3\},\{1,3,2\},\{2,1,3\},\{2,3,1\},\{3,1,2\},\{3,2,1\}\}$$ I want to drop elements found in sets B and C from A. $$B=\{\{1,3,2\},\{2,1,3\}\}$$ $$C=\{\{3,1,2\},\{3,2,1\}\}$$ ...
user avatar
3 votes
1 answer
43 views

Choosing numbers whose divisors can be partitioned into subsets having the equal sum

How can we find the list of natural numbers between 100 to 10000, whose positive divisors can be partitioned into three subsets such that sum of all the elements in three subsets will be equal?
user avatar
4 votes
4 answers
387 views

How to generate Venn diagram from a universe and 3 random sets?

Given a universe u with random numbers between 1 and 50 and three sets a,b,c, that have random numbers a between 3 and 30, b between 2 and 40 and c between 4 and 49 How can I represent the sets a, b ...
user avatar
  • 480
2 votes
2 answers
159 views

How can I subtract and calculate the complement of a pair of sets? [closed]

I cannot properly implement these operations. How can I do it? This is a reduced example: A={2,3,4} B={2,4,6} C={1,2,3,4} Find ...
user avatar
  • 417
4 votes
1 answer
129 views

Choosing a subset of a set based on the sum of its elements

How can we choose a subset of a set based on the sum of the elements of the subset? For instance, n=6 dn=Divisors[n] sn=DivisorSum[n,#&] Is it possible to ...
user avatar
  • 41
7 votes
3 answers
309 views

Is there a function to generate “subsets” allowing duplicates?

I allow them to be chosen more than once (e.g. allow {1,1}). (A subset means every element is chosen once or less) Also I neglect the order (e.g. ...
user avatar
  • 75
3 votes
1 answer
60 views

select subset of combinations based on condition

My question is about choosing a subset of combinations within a list, based on a condition. Fot example, a shop sells 26 products. The name of a product starts with a letter. Each product has a price. ...
user avatar
6 votes
1 answer
156 views

How to obtain all subsets of a list with repetition?

I'd like to generate all lists of length m containing all possible element combinations from a given list of length n with ...
user avatar
  • 2,433
2 votes
2 answers
62 views

List X is a starter of List Y

For lists X and Y, let's define a term 'X is a starter of Y' to be 'there exist a list Z such that Y = Join[X,Z]'. Until now I've used following code for 'X is a starter of Y' ...
user avatar
  • 2,451
2 votes
1 answer
24 views

ordered set inclusion 2

Slightly change the previous question, ordered set inclusion, Now, consider $A=\{2,3\}$ and $B=\{2,3,4,5\}, C=\{5,2,4,3\}$, Now I want to make element $\{2,3\}$ is in $B$ as well as $C$, what can be ...
user avatar
  • 335
2 votes
1 answer
33 views

ordered set inclusion

Suppose I have a ordered set $A=\{2,3\}$ and $B=\{2,3,4\}$ and $C=\{2,4,3\}$. Is there any mathematica command whether $A\subset B$ gives true(or 1) but $A$ which is not a subset of $C$ gives false(or ...
user avatar
  • 335
4 votes
2 answers
182 views

How do you turn a normal intersection to a strict one for arbitrary number of sets?

What is the best way to generalize the following interaction of 3 sets to any number of sets: ...
user avatar
  • 8,105
4 votes
4 answers
115 views

Delete the sublist which can be others' subsets

given lst = {{1, 5}, {2, 5}, {6, 8}, {6, 8, 9}} I want to remove all the sublists which is any other's subset. For the above example, remove ...
user avatar
  • 6,617
2 votes
1 answer
101 views

k-subsets of several sets?

Problem: Let A and B be lists of lists of integers. I wish to find every k-element set, ...
user avatar
  • 1,095
1 vote
0 answers
55 views

How to determine the domain (intersection and disjoint set) of two functions define on a set? [closed]

Suppose I have two multivariate functions $f(x,y,z)$ and $g(x,y,z)$ such that $0<x<1,0<y<1,0<z<1$. $f(x,y,z)$ is defined on values satisfying $\{0<x<1,0<y<1/2, z>y\}$ ...
user avatar
  • 147
1 vote
0 answers
45 views

Letter Combination Plot

How do I make a plot that displays the total number of letter combinations of n letters (from n=1 to 26)? I've been trying with subset but can't get the syntax right.
user avatar
  • 11
12 votes
7 answers
863 views

Generate only unique combinations when input contains duplicates

I have a list with repeated elements, such as list = {a, a, b, c, c, c} and I'd like a list of the unique ways to choose 3 elements from it: ...
user avatar
0 votes
0 answers
115 views

Symbolic Subset Sum Problem

I am interested in solving the following problem with Mathematica, but I do not know if it can be done or how it could be done. Given a finite set of terms $M=\{a_i(p_1, \ldots,p_m) \}_{i=1}^n$, ...
user avatar
  • 101
6 votes
2 answers
206 views

Graph that visualizes subset relations

First, off I am a bloody beginner when it comes to programming in general and Mathematica in particular. I only started using it so I can make sense of my suggestions for the semantics in my syntax ...
user avatar
  • 151
4 votes
2 answers
132 views

Simple way to decompose a lists in a certain way?

I want to decompose one list into sublists (each sublist is given by certain lengh and the sum of every sublist is given by the maximun number in lists). For ...
user avatar
  • 1,556
2 votes
1 answer
95 views

Creating pairs of non-intersecting set from a given set

Let's say I have a set {a,b,c,d} and I want to create a list of pairs {{a,b,c,d},{}},{{a,b,c},{d}},{{a,b,c},{}},... such that there is no intersection between each pair, and they do not need to use ...
user avatar
  • 21
0 votes
1 answer
48 views

How to find disjoint subsets such that union of the sets give the motherset or main set?

Let us define a set $\mathcal{S}=\{1,2, 3,\cdots,67\}$. I have a list of 132 subsets. I want to obtain 16(or 17) mutually exclusive subsets such that union of such 16(or 17) is equal to $\mathcal{S}$...
user avatar
0 votes
0 answers
101 views

Generating all possible subgraphs from an adjacency matrix

I have an adjacency matrix given by am. I want to generate all possible subgraphs with 6 nodes. Here is the code I am using to generate them. But, I am getting some error: ...
user avatar
2 votes
1 answer
73 views

Calculate plausibility in Dempster-Shafer theory

I want to use Mathematica to show which subsets of a power set are required to calculate the plausibility for a given set in a power set. This has lead me to compute a summation with a ...
user avatar
6 votes
1 answer
163 views

Generate list of tuples, modulo PermutationGroup

I have a permutation group, e.g. g = PermutationGroup[{Cycles[{{1, 2}}]}] but not necessarily limited to a single generating cycle. What I want is to create a ...
user avatar
  • 141
0 votes
0 answers
92 views

Iterating over pairs in a list

Take a look at this code: ...
user avatar
  • 101
0 votes
1 answer
94 views

Delete duplicates and sort a list of sets separately? [closed]

I have a set where it has three subsets. I want to have each element of each subsets appears only once, sorted, but the order of subsets does not change. For example: I want to get from $$ \{\{5,2,2,3\...
user avatar
  • 798
6 votes
2 answers
558 views

Subsets of a multiset

The function Subsets[] returns the subsets of a finite set of elements. This function has a shortcoming in that it treats repeated elements distinctively. Is there ...
user avatar
2 votes
2 answers
168 views

Finding maximal elements of partially ordered sets

I am dealing with partially ordered sets $\Gamma$, which I represent as directed graphs with an edge going from $a$ to $b$ if $a \leq b$ in $\Gamma$. For example the following graph, ...
user avatar
  • 545
5 votes
4 answers
690 views

Summation over integers satisfying some conditions

$n$ is a fixed positive integer and $p$ is the largest prime $\le n$: p = Prime[PrimePi[n]] For each subset $L$ of positive composite integers less than or ...
user avatar
1 vote
1 answer
343 views

Creating subsets of lists of lists which have certain properties

PREFACE: This question is about a proper algorithm and its implementation. I will explain the problem as detailed as possible and will give my current algorithm as well as two more possible solutions ...
user avatar
  • 321
0 votes
1 answer
55 views

determine the structure of Data in sum of two subsets Modulus $n$

I wrote a code below to determine the cases when two subsets of a set $\mathbb{Z_n}=\{0,1,2,\ldots,n-1\}$ are added together element by element (without removing the multiplicity) in $\mathbb{Z_n}$ ...
user avatar
  • 798
10 votes
6 answers
795 views

Is there concise code for the list operation I want to perform?

Is there any concise syntax for the following partitioning of a list. Given {1, 2, 3, 4}, I want to get the output as shown below. I have tried various function ...
user avatar
  • 101
1 vote
3 answers
100 views

Computing $\bigcup_{n=1,5}X_{n}$? when $X_{n}=n+1,n+2,...,2n$

How do I correctly compute $\bigcup_{n=1,5}X_{n}$? when $X_{n}=n+1,n+2,...,2n$ for each $n \in \mathbb{N^{+}}$? When I do the calculation manually, I get the following results: $n=1:\{2\}$ $n=2:\{3,...
user avatar
  • 247
1 vote
1 answer
128 views

Reduce a set expression in Mahematica [closed]

For example: Given $ A\subset B $ reduce $\left [ (B\triangle C )\bigcap (A-B)\bigcap (A \triangle B) \right ]\bigcup B $ $A \triangle B$ denotes the symmetric difference of the two sets. Edit ...
user avatar
  • 13
10 votes
5 answers
878 views

unordered Tuples [duplicate]

I gather from this question that there is no primitive to build unordered tuples. That is, I want to do the equivalent of the following: ...
user avatar
  • 3,975
9 votes
2 answers
146 views

Product of set elements not exceeding a bound

I have a set of distinct positive integers l (if you wish, you may assume it is a list ordered by size), and a bound lim. In ...
user avatar
  • 3,975
1 vote
1 answer
111 views

Group list by rules in sequence using DateDifference and Total

I have a list and would like to group it into sublists using a couple rules. First rule: the date difference between sequential elements is less than 3. Second Rule: the total of the second ...
user avatar
  • 1,269
1 vote
1 answer
58 views

Check union closedness of set

I have defined two sets set1[n_] := Table[i, {i, 1, n}]; set2[n_] := Subsets[Delete[Subsets[set[n]], 1]]; Now, I want to check whether an element of set2[n] is ...
user avatar
0 votes
1 answer
88 views

Correlation of subsets of two sets of data [closed]

For instance, I have: data1 = {{1, 2, 3}, {2, 3, 4}, {3, 4, 5}}; data2 = {{3, 2, 1}, {6, 7, 8}, {5, 4, 3}}; I want to calculate the correlation that ...
user avatar
2 votes
1 answer
198 views

Consecutive generation of subsets [duplicate]

It is well known that the array of subsets of even small set is very big. This leads to problems with machine memory. Is there an effective way to generate subsets sequentially?
user avatar
  • 459
6 votes
1 answer
337 views

Find independent vertex sets

I'm trying to find all independent vertex sets for a given graph. Note that they may not be maximal independent sets. There is a function in Mathematica called ...
user avatar
  • 455
10 votes
4 answers
425 views

Efficient way to make subsets of list with placeholders

I have an arbitrary list of unique elements: lst = {a, b, c, d} Documentation allows finding subsets with same number of elements, say ...
user avatar
  • 4,735
4 votes
0 answers
96 views

Create an adequate 'training set' to train a ClassifierFunction which performs the role of the built-in `SubsetQ`

I am trying to "grow" my own SubsetQ function using Machine Learning methods. My cSubsetQ when given two lists (listA and listB)...
user avatar
1 vote
1 answer
76 views

Choosing sets from Subsets[list] part 2

Piggybacking off of this question, say if I wanted to exclude sets which weren't the union of elements of the list of lists. For example: ...
user avatar
  • 97
6 votes
5 answers
419 views

Choosing sets from Subset[list]

Say I have a set, S, and I take Subsets[S] (the power set of S). For example: S={a,b,c} Subsets[S]={{}, {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c}} How can ...
user avatar
  • 97
2 votes
2 answers
251 views

Refining subset relations

People who do combinatorics (like me) are often faced with the following problem: For a list of combinatorial objects (vectors, permutations graphs,etc.), we know what multi-set of values it ...
user avatar
-2 votes
2 answers
138 views

How to efficiently find all sets of primes that add to a given number?

For large numbers the naive approach falls down: Select[Subsets[Range[1, 4]], PrimeQ@Total@# &] {{2},{3},{1,2},{1,4},{2,3},{3,4},{1,2,4}} ...
user avatar
  • 30.3k
20 votes
5 answers
2k views

How to delete subsets quickly?

I have some data like this: ...
user avatar
  • 3,623
2 votes
3 answers
143 views

Efficient extraction of a subset

The context is molecular dynamics. The data is in the format (index_1, index_2, distance). The goal is to find all of the distances to the neighbors of point index_0 and to present a set listing the ...
user avatar
  • 956