by Zohaib
Last Updated January 12, 2018 16:05 PM

If we have different objects,

```
[A1, A2, A3, B1, B2, B3, B4, B5]
```

Some calculations will be performed to find compatible objects. For example, lets assume following 3 sets were formed and every set contains compatible objects:

- {A1, B2}
- {A3, B2}
- {A1, A3, B4, B5}

Now we need to perform filtering. One node can participate only once. For example, if `B2`

has made a pair with `A1`

, then `B2`

can not participate in any other set. Which means, if we select `set 1`

, then `set 2`

will be deleted because `B2`

has already participated. And set 3 will be deleted because A1 has already participated.

Now we need to do filtering such that we maximize number of objects being utilized. If we select `set 1`

, then we are only utilizing `A1 and B2`

.

Thus, optimal way would be to select `set 3`

which is utilizing 4 objects.

Right now, i have a complex function which goes through list of sets recursively and keeps on adjusting until no changes are made to existing sets. This is not only inefficient, but it might not work in cases where changing sets can cause ripple effect.

I am not looking for coded solution, but just a guidance that is there any graph algorithm which I should study?

- Serverfault Help
- Superuser Help
- Ubuntu Help
- Webapps Help
- Webmasters Help
- Programmers Help
- Dba Help
- Drupal Help
- Wordpress Help
- Magento Help
- Joomla Help
- Android Help
- Apple Help
- Game Help
- Gaming Help
- Blender Help
- Ux Help
- Cooking Help
- Photo Help
- Stats Help
- Math Help
- Diy Help
- Gis Help
- Tex Help
- Meta Help
- Electronics Help
- Stackoverflow Help
- Bitcoin Help
- Ethereum Help