title: Merging set of combinations into a larger set (Reverse Combinations)
body: <p>I'm trying to create a function which takes a list of subsets, and merge them into larger sets if all combinations are present.</p>
  <p>Basically, let's say we have n=4 (i.e index_domain = {0,1,2,3}) and we have the following combinations as input</p>
  <pre><code>[(0, 2), (0, 3), (1, 3), (2, 3)]
  </code></pre>
  <p>the function should take this input and generate the following output:</p>
  <pre><code>[(0, 2, 3), (1, 3)]
  </code></pre>
  <p>So, (0, 2, 3) since all of the combinations (combination of 2) are present in the input list. (1, 3) remains as is since we don't have another combination of 1.</p>
  <p>For an index domain D ⊆ ℕ and input list L, the main features of the case are:</p>
  <ul>
  <li>L can be an empty list. (Off topic)</li>
  <li>L always contains combination of 2s, i.e pairs, if not empty.</li>
  <li>The pairs are symmetric and only one of the pairs are included in L (no duplicates). That is, if a pair (i, j) should be included in L, then pair (i, j) is present in L and (j, i) is never included, where i &lt; j and i, j ∈ D.</li>
  <li>There is never a pair (i, i) in L, i ∈ D.</li>
  </ul>
  <p>Simply it is combinations(n, 2) in reverse. I have searched for this topic &quot;reverse combinations&quot;, and I've yet to find an appropriate resource so far. I've considered some options like  double iteratation of the input to check if all combinations are there, but that's not the best way of doing it. I've yet to come up with an efficient solution. Appreciate any idea for an effective solution.</p>
  <p>Thanks.</p>