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
2answers
55 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 ...
2
votes
1answer
37 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 ...
0
votes
1answer
29 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}$...
0
votes
0answers
55 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: ...
2
votes
1answer
47 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 ...
6
votes
1answer
110 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 ...
0
votes
0answers
59 views

Iterating over pairs in a list

Take a look at this code: ...
0
votes
1answer
51 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\...
5
votes
2answers
202 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 ...
2
votes
2answers
87 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, ...
5
votes
4answers
454 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 ...
1
vote
1answer
178 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 ...
0
votes
1answer
49 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}$ ...
10
votes
6answers
769 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 ...
1
vote
3answers
74 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,...
1
vote
1answer
87 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 ...
10
votes
5answers
691 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: ...
9
votes
2answers
138 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 ...
1
vote
1answer
91 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 ...
1
vote
1answer
51 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 ...
0
votes
1answer
81 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 ...
2
votes
1answer
136 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?
4
votes
1answer
238 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 ...
10
votes
4answers
376 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 ...
4
votes
0answers
87 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)...
1
vote
1answer
63 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: ...
6
votes
5answers
305 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 ...
2
votes
2answers
217 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 ...
-2
votes
2answers
129 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}} ...
19
votes
5answers
1k views

How to delete subsets quickly?

I have some data like this: ...
2
votes
3answers
137 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 ...
2
votes
4answers
163 views

calculating subsets of a matrix (L=40X40)

I need to calculate all $k$-possible subsets$(k:1,L)$ of matrix with size $L$. I am using subset function as following, ...
1
vote
4answers
292 views

Find all disjoint subsets of equal length

Suppose that $A$ is a list with $n$ elements where $n$ is even. I want to write a function that returns all pairs $(A_1,A_2)$ where the sets $A_1$ and $A_2$ each have length $\frac{n}{2}$, $A_1 \cap ...
1
vote
1answer
324 views

How to subset datasets in Mathematica 10 [closed]

I'm sorry if this is obvious but I can't find a way to select only a certain amount of columns of a dataset (or delete a certain amount of columns from a dataset) using the key of each column. I ...
3
votes
2answers
113 views

Efficient subsetting and averaging

The following code aims to average 4 groups of the values vector. Which elements belong to each group is determined by the indic ...
5
votes
4answers
282 views

Signed power set of a list

Given {a, b, c, ...} with $n$ elements generate a list with $2^n$ elements. For example, if the list were {a, b, c}, then the ...
1
vote
4answers
211 views

Need an efficient way to do this list manipulation

Lets say i have two lists with me as given below: l1 = {4, 6, 8, 9, 10, 12}; l2 = {2, 3, 4, 5, 6, 7}; Now i have a function S2P(details irrelevant) which takes ...