Choosing mutually exclusive pairs efficiently

前端 未结 4 1959
滥情空心
滥情空心 2021-01-17 19:12

This is a problem that could be done with some type of brute-force algorithm, but I was wondering if there are some efficient ways of doing this.

Let\'s assume that

4条回答
  •  庸人自扰
    2021-01-17 20:02

    This problem can be recast in terms of graph theory. Nodes of the graph are the pairs you are given. Two nodes are connected if the pairs have a number in common. Your problem is to find a maximum independent set.

    Maximum independent set is equivalent to finding a maximum clique, which is both NP-complete and "hard to approximate". However, in this particular case, the graphs are of a special type called "claw-free" (http://en.wikipedia.org/wiki/Claw-free_graph) because if a node is connected to three other nodes, at least two of those nodes must share a common number and so are themselves connected.

    It turns out that for the special case of claw-free graphs, the maximum independent set problem can be solved in polynomial time: http://en.wikipedia.org/wiki/Claw-free_graph#Independent_sets.

提交回复
热议问题