Minimal set that have at least one element in n sets

微笑、不失礼 提交于 2021-02-10 09:56:14

问题


I'm solving an algorithmic problem and managed to decompose it. Here is the sub problem I have:

I have n sets, let's say {1,2},{2,3},{3,4} I need to find the smallest set that have at least one element in every of these n sets, the solution here is: {2,3}.

It's not a greedy problem, think about {1},{1,3},{1,3,4},{2,3,4},{2,3},{2} the solution is {1,2} even though 3 have the biggest frequency.

Maybe there is also a common name for that algorithm, I tried to search but didn't manage to find anything useful.


回答1:


This sounds like the minimum vertex cover problem, which is NP-complete.

Let each of the values be a vertex and two vertices are adjacent if they coexist in the same set somewhere. By this construction, any element in any set will be at most distance 1 away from a cover vertex, therefore a minimum vertex cover will cover the sets. Another way to think about it, if a set does not contain a cover vertex, then there must be at least one edge in the set that doesn't include a cover vertex by construction. This contradicts the cover property, however, therefore every set will contain a cover vertex.



来源:https://stackoverflow.com/questions/48139675/minimal-set-that-have-at-least-one-element-in-n-sets

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!