Finding the partitions of a set which respect to some rules

89 Views Asked by At

Let's take two elements from different domains.

The first element f ∈ {a, b, c, d} and s ∈ in N

I also have a list of relationship between these elements which can be represented as it follows

+--------+--------+
| f      | s      |
+--------+--------+
| a      | 1      |
+--------+--------+
| a      | 2      |
+--------+--------+
| b      | 1      |
+--------+--------+
| b      | 2      |
+--------+--------+
| c      | 3      |
+--------+--------+
| d      | 4      |
+--------+--------+
| d      | 5      |
+--------+--------+

Two elements are in relationship if they are listed in that table on the same row. So for example a and 1 are related.

The scope is to partition the bigger set which contains {a, b, c, d, 1, 2, 3, 4, 5} in smaller sets which are

  • mutually exclusive
  • The union of all the partition sets must equal the initial set
  • Each partition set must contain all the elements which are related together.

This means that it's acceptable to have 3 partitions like:

{a, b, 1, 2}, {c, 3}, {d, 4, 5}

But we cannot have

{a, b, 1}, {c, 2, 3}, {d, 4, 5}

Since a is related to 2 so they must be in the same set.

I would like to find one or more acceptable partitions. I found the solution manually but I couldn't get the theory which is leading to the solution.