Блог пользователя throwaway_1234

Автор throwaway_1234, история, 8 лет назад, По-английски

I thought of this problem and I was wondering if there is any polynomial time solution?

Given a weighted tree of N nodes, pick K nodes such that sum of distances from each node to the nearest picked node is minimized.

For K = 1, the answer is the centroid of the tree. What about K > 1 ?

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I think you can binary search for the distance possible, and then use a greedy algorithm, where you take nodes as high as you can in the tree.

»
8 лет назад, # |
  Проголосовать: нравится +26 Проголосовать: не нравится

Your problem (on general graphs) is called as "K-median". A quick search reveals that the problem on trees can be solved in O(KN2) time [1].

[1] Tamir, A. An O(pn2) algorithm for the p-median and related problems on tree graphs.

  • »
    »
    8 лет назад, # ^ |
      Проголосовать: нравится +5 Проголосовать: не нравится

    Thanks!

    The O(pn2) algorithms also solves for a much more general version of the problem (with weighted vertices and custom distance functions) so that's cool!