开发者

Algorithm to find fewest number of tags that encompass all items?

开发者 https://www.devze.com 2023-01-19 03:17 出处:网络
I\'m thinking this might be NP-complete, but I\'ll ask 开发者_Go百科anyway. Greedy algorithms don\'t seem to work in my head.

I'm thinking this might be NP-complete, but I'll ask 开发者_Go百科anyway. Greedy algorithms don't seem to work in my head.

Given a set of items, each with 1 or more tags, I want to find the smallest set of tags that cover all the items.

Edit: See my "solution" here.


This is the Set Cover problem, which is NP-complete. Each tag defines a subset of your list of items, and you want to find the minimum number of subsets (tags) whose union equals the full list of items.

0

精彩评论

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