<p>This is a special case of the <a href="http://en.wikipedia.org/wiki/Set_packing" rel="nofollow">Maximum Set Packing Problem</a> and both problem A and B are <strong>NP-Complete</strong>. Note that the problem is simply a <a href="http://en.wikipedia.org/wiki/Matching_%28graph_theory%29" rel="nofollow">matching problem</a> if $n=2$ and is also easy if $n=1$. So I'll assume $n \ge 3$.</p>

<p>Instead of asking the question,</p>

<blockquote>
  <p>Are there $M$ disjoint sets among the $P$ sets? </p>
</blockquote>

<p>Let's ask the following question</p>

<blockquote>
  <p>What is the maximum number of disjoint sets we can obtain from the $P$ sets?</p>
</blockquote>

<p>It is clear that if the second question is answerable in polynomial time, then so is the first since all we have to do is compare this maximum value to $M$ and output <strong>YES</strong> if $M$ is less than or equal to this maximum and <strong>NO</strong> otherwise.<br></p>

<p>Also, if the first question is answerable in polynomial time, then the second is too since we can use binary search on $M$ and obtain the answer to the second question and only add a factor of $O(\log{M})$</p>

<p>So we can conclude that both questions are equivalent. i.e. Question 1 is polylomial time solvable if and only if Question 2 is too.<br></p>

<p>It is also clear that the problems are in NP since we can easily verify that the $M$ sets outputed are disjoint.<br></p>

<p>So the question now is how do we reduce a known NP-Hard problem to this? To do this we reduce from the <a href="http://en.wikipedia.org/wiki/Set_packing" rel="nofollow">maximum set packing</a> problem. I'll simply focus on problem A since problem B can easily be shown to be hard by setting $k=n-1$</p>

<p>Consider an arbitrary instance of the maximum set packing problem $T$. Note that the only difference between problem A and the original maximum set packing problem is that in problem A, the size of the sets have to be equal. Let $t$ be the maximum cardinality among all sets in $T$. If every set in $T$ have the same cardinality, we are done and the set cover problem is exactlly problem A. Now suppose that for some set $S_i \in T$, we have $|S_i| &lt; t$. We simply add $(t-|S_i|)$ elements to $S_i$ which are not elements of any set in $T$. We repeat this process until all sets $S_i \in T$ have the same size. It is clear that adding new elements in this way does not change the size of the maximum number of disjoint sets.</p>

<p>So, if we can solve problem $A$ in polynomial time, we can solve the maximum set packing problem in polynomial time since all we have to do is remove the extra elements that we have added, and doing this doesn't change the size of the maximum number of disjoint sets in $T$.</p>

<p><strong>EDIT - Some Additional information about problem B</strong><br></p>

<p>Suppose problem B has a polynomial time solution, now consider an arbitrary instance $T$ of problem A with $n$ elements per set. Now we add a dummy element $d$ to each set in $T$. We now ask the following question.</p>

<blockquote>
  <p>What is the maximum number of disjoint sets we can obtain by taking
  $n$ elements from each set?</p>
</blockquote>

<p>Now we know that among the sets in the maximum, at most one of them can contain the dummy element, hence if the answer we get as the maximum is $M$, then the actual maximum number of sets in instance $T$ (our original problem A) is either $M$ or $(M-1)$, but this gives a constant factor approximation for maximum set packing. And such an approximation is only possible if $P=NP$. So problem B is also hard.</p>

CC BY-SA 3.0
2014-02-17T08:03:10.640Z
Regarding problem B: if you add a dummy element to all the sets of Problem A, you get sets of size $n+1$. In the example that appears in my question ($n=3, P=3$), you will get that the maximum number of disjoint sets of size $n-1=2$ is 3: $\left\{ {1,d} \right\},\left\{ {2,3} \right\},\left\{ {4,5} \right\}$. However, the solution to Problem A is that there is only one set. In other words, I don't see how a solution for Problem B gives a constant factor approximation to Problem A.
MJK
CC BY-SA 3.0
2014-02-17T12:52:34.463Z
If you add the dummy element, you have sets $A′= \left\{ {1,2,3,d} \right\}, B′= \left\{ {2,3,4,d} \right\}$ and $C′= \left\{ {3,4,5,d} \right\} $. This new instance with $n=4$ is the instance of problem A we are interested in. Now run the supposed B algorithm on these sets i.e. $n=4$ and $k=3$. That's what I'm saying. Note that the problem reduces to finding a maximum matching if $n=2$ or $k=2$.
Obinna Okechukwu
CC BY-SA 3.0
2014-02-16T04:37:38.897Z
2014-02-17T15:32:58.680Z
2014-02-17T15:32:58.680Z
Obinna Okechukwu
<p>Assume that I have $P$ sets with elements taken from $r$ possible ones. Each set is of size $n$ ($n&lt;r$), where the sets can overlap. I want to determine whether the following two problems are NP-complete or not:</p>

<p><strong>Problem A.</strong> Are there $M$ ($1 \le M \le P$) <strong>distinct</strong> sets within the $P$ sets (i.e., their pair-wise intersection is empty)?</p>

<p><strong>Problem B.</strong> Now $k$ ($k&lt;n$) elements can be chosen from each set. Are there $L$ ($1 \le L \le P$) <strong>distinct</strong> sets of size $k$ each within the $P$ sets? Note that only one set of $k$ elements can be taken from each set of $n$ elements.</p>

<p><strong>Remark</strong>: I am mainly interested in the case where $k,n$ are fixed ($n \ge 2, k \ge 2$).</p>

<p>I think that Problem A can be thought as an $n$-uniform $r$-partite hyper-graph matching problem. That is, we have the elements of $r$ as vertices, and each hyper-edge contains a subset of $n$ vertices of the graph.</p>

<ol>
<li><p>In the $n$-uniform $r$-partite hyper-graph matching problem NP-complete?</p></li>
<li><p>I think that Problem B is equivalent to finding the number of distinct hyper-edges of cardinality $k$ taken from hyper-edges of cardinality $n$. Is this restricted version (in the sense that each $k$-cardinality set is taken from a pre-chosen set of $n$ elements rather than taken arbitrarily from $r$ elements) of Problem A NP-complete?</p></li>
</ol>

<p><strong>Example</strong> ($n=3,r=5, P=3$):</p>

<p>$A=\{1,2,3\}$, $B=\{2,3,4\}$, $C=\{3,4,5\}$</p>

<p>If $k=n=3$, there is only $M=1$ one distinct set, which is $A$ or $B$ or $C$, since each of the pairs $(A,B)$, $(A,C)$, $(B,C)$ has non-empty intersection.</p>

<p>If $k=2$, we have $L=2$ distinct sets: one solution is $\{1,2\}$, $\{3,4\}$ (subsets of $A$ and $B$).</p>

<graph-theory><np-hardness>
Complexity of finding the maximal number of pair-wise disjoint sets
MJK
# Complexity of finding the maximal number of pair-wise disjoint sets

(Asked by: username_0 on 2014-02-13)

Assume that I have $P$ sets with elements taken from $r$ possible ones. Each set is of size $n$ ($n

**Problem A.** Are there $M$ ($1 \le M \le P$) **distinct** sets within the $P$ sets (i.e., their pair-wise intersection is empty)?

**Problem B.** Now $k$ ($kdistinct sets of size $k$ each within the $P$ sets? Note that only one set of $k$ elements can be taken from each set of $n$ elements.

**Remark**: I am mainly interested in the case where $k,n$ are fixed ($n \ge 2, k \ge 2$).

I think that Problem A can be thought as an $n$-uniform $r$-partite hyper-graph matching problem. That is, we have the elements of $r$ as vertices, and each hyper-edge contains a subset of $n$ vertices of the graph.

1. In the $n$-uniform $r$-partite hyper-graph matching problem NP-complete?
2. I think that Problem B is equivalent to finding the number of distinct hyper-edges of cardinality $k$ taken from hyper-edges of cardinality $n$. Is this restricted version (in the sense that each $k$-cardinality set is taken from a pre-chosen set of $n$ elements rather than taken arbitrarily from $r$ elements) of Problem A NP-complete?

**Example** ($n=3,r=5, P=3$):

$A=\{1,2,3\}$, $B=\{2,3,4\}$, $C=\{3,4,5\}$

If $k=n=3$, there is only $M=1$ one distinct set, which is $A$ or $B$ or $C$, since each of the pairs $(A,B)$, $(A,C)$, $(B,C)$ has non-empty intersection.

If $k=2$, we have $L=2$ distinct sets: one solution is $\{1,2\}$, $\{3,4\}$ (subsets of $A$ and $B$).

**Tags:** graph-theory, np-hardness


---

## 1 answers

### Answer by username_1 on 2014-02-16. Score: 2 | Accepted answer

This is a special case of the [Maximum Set Packing Problem](http://en.wikipedia.org/wiki/Set_packing) and both problem A and B are **NP-Complete**. Note that the problem is simply a [matching problem](http://en.wikipedia.org/wiki/Matching_%28graph_theory%29) if $n=2$ and is also easy if $n=1$. So I'll assume $n \ge 3$.

Instead of asking the question,

> Are there $M$ disjoint sets among the $P$ sets?

Let's ask the following question

> What is the maximum number of disjoint sets we can obtain from the $P$ sets?

It is clear that if the second question is answerable in polynomial time, then so is the first since all we have to do is compare this maximum value to $M$ and output **YES** if $M$ is less than or equal to this maximum and **NO** otherwise.

Also, if the first question is answerable in polynomial time, then the second is too since we can use binary search on $M$ and obtain the answer to the second question and only add a factor of $O(\log{M})$

So we can conclude that both questions are equivalent. i.e. Question 1 is polylomial time solvable if and only if Question 2 is too.

It is also clear that the problems are in NP since we can easily verify that the $M$ sets outputed are disjoint.

So the question now is how do we reduce a known NP-Hard problem to this? To do this we reduce from the [maximum set packing](http://en.wikipedia.org/wiki/Set_packing) problem. I'll simply focus on problem A since problem B can easily be shown to be hard by setting $k=n-1$

Consider an arbitrary instance of the maximum set packing problem $T$. Note that the only difference between problem A and the original maximum set packing problem is that in problem A, the size of the sets have to be equal. Let $t$ be the maximum cardinality among all sets in $T$. If every set in $T$ have the same cardinality, we are done and the set cover problem is exactlly problem A. Now suppose that for some set $S\_i \in T$, we have $|S\_i| < t$. We simply add $(t-|S\_i|)$ elements to $S\_i$ which are not elements of any set in $T$. We repeat this process until all sets $S\_i \in T$ have the same size. It is clear that adding new elements in this way does not change the size of the maximum number of disjoint sets.

So, if we can solve problem $A$ in polynomial time, we can solve the maximum set packing problem in polynomial time since all we have to do is remove the extra elements that we have added, and doing this doesn't change the size of the maximum number of disjoint sets in $T$.

**EDIT - Some Additional information about problem B**

Suppose problem B has a polynomial time solution, now consider an arbitrary instance $T$ of problem A with $n$ elements per set. Now we add a dummy element $d$ to each set in $T$. We now ask the following question.

> What is the maximum number of disjoint sets we can obtain by taking
> $n$ elements from each set?

Now we know that among the sets in the maximum, at most one of them can contain the dummy element, hence if the answer we get as the maximum is $M$, then the actual maximum number of sets in instance $T$ (our original problem A) is either $M$ or $(M-1)$, but this gives a constant factor approximation for maximum set packing. And such an approximation is only possible if $P=NP$. So problem B is also hard.

> **Comments:**
> **username_0**: Regarding problem B: if you add a dummy element to all the sets of Problem A, you get sets of size $n+1$. In the example that appears in my question ($n=3, P=3$), you will get that the maximum number of disjoint sets of size $n-1=2$ is 3: $\left\{ {1,d} \right\},\left\{ {2,3} \right\},\left\{ {4,5} \right\}$. However, the solution to Problem A is that there is only one set. In other words, I don't see how a solution for Problem B gives a constant factor approximation to Problem A.  
> **username_1**: If you add the dummy element, you have sets $A′= \left\{ {1,2,3,d} \right\}, B′= \left\{ {2,3,4,d} \right\}$ and $C′= \left\{ {3,4,5,d} \right\} $. This new instance with $n=4$ is the instance of problem A we are interested in. Now run the supposed B algorithm on these sets i.e. $n=4$ and $k=3$. That's what I'm saying. Note that the problem reduces to finding a maximum matching if $n=2$ or $k=2$.  

---

