开发者

Minimal grouping algorithm

开发者 https://www.devze.com 2023-03-10 23:27 出处:网络
I have a set of values, each value has a possible group. The value can ve repeating but in different group.

I have a set of values, each value has a possible group. The value can ve repeating but in different group.

What will be an optimal algorithm to get minimum number of groups

A sample set: (12, group b) (38, group a) (12, group a)

Desired outcome: (38, group a) (12, group a开发者_运维问答)

(only one group is used)

-- edit: I need an algorithm to find minimum number of groups from a set like the sample above. If i would have a bad algorithm it will select (12, group b) (38, group a) This is 2 groups for the same values instead of using one, not what i want


If I understand the question correctly, this is the Set cover problem

The greedy algorithm as described in the link starts with group a and then terminates, as this already covers all.

Note that in general it yields only an approximation to the optimal solution.

0

精彩评论

暂无评论...
验证码 换一张
取 消