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

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

Problem

TL;DR version: You are given a bipartite graph with atmost 1000 vertices on each side. M (upto 1,000,000) edges are added one by one. Compute the minimum vertex cover after each addition.

Clarification: You need to compute the minimum vertex cover / maximum matching everytime an edge is added.

Any ideas?

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

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

Kőnig's theorem will definitely help

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

    Obviously. However, the problem is that I cannot compute the maximum matching naively 1e6 times....

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

      Maybe the trick is to effectively check (after adding each edge) whether there exists a new augmenting path. There will be no more than min(N, M) such paths, so we can afford running some calculations on the entire graph after finding each augmenting path. Author says, that his approach uses about 700kk operations, so this may be it.

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

        "Maybe the trick is to effectively check (after adding each edge) whether there exists a new augmenting path"

        This is what I'm seeking help on...

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

          Ok, so just build a directed graph with one vertex representing all unmatched vertices in the first set (vertex A) and other one representing unmatched vertices in the second set (vertex B). Other vertices will correspond to pairs of matched vertices. Each unmatched edge in original graph connecting vertices a and b will translate to directed edge between a' and b', where v' is a vertex in new graph corresponding to original vertex v in the old graph. Direction of this edge will be from a' to b' if a was in the same set as A in our original graph and from b' to a' in the opposite case. The task now is to determine whether after adding new edge there exist a path from A to B.

»
9 лет назад, # |
Rev. 2   Проголосовать: нравится +5 Проголосовать: не нравится

I know one of the guys who solved that problem, lucasmelo, and he only solved it because I kept bothering him to help me with it, though you can see I still don't have an accepted in it = ).

If I remember correctly (I can't find our talk) he checks, when a new monster arrives, if it is covered by his choice of guards in the previous iteration, if it is our answer is the same from the previous iteration. Otherwise he runs the hopcroft-karp code from wikipedia and gets a new min vertex cover. I also think he did the problem backwards (going from all monsters to zero monsters) but I can't think now how he did that

I don't know if that was the intended solution as his time is way slower than the other guy time.