irkstepanov's blog

By irkstepanov, history, 6 years ago, In English

Hiya!

I've been recently dealing with the classical problem of finding the minimum vertex cover in a bipartite graph. The common approach is to set direction to all edges and run DFS from all vertices of the left part outside of the matching. However, this solution seems too clever for me.

A more natural thing is to do the following. Clearly, the minimum vertex cover should contain exactly one vertex for every edge in the maximum matching M. So let's assign a boolean variable for every edge in M, say, xi = 0 if the i-th edge adds its left end to the vertex cover. One can build all the dependencies over these variables. For example, if there exist edges and , while w is not saturated by M, we have to set xi equal to 0, because there is no other way to cover the edge (u, w). All the other cases are handled trivially.

As a result, we obtain a full system of restrictions for the set of variables. Finding an arbitrary valid assignment is a classical 2-SAT problem. So we have basically reduced the minimum vertex cover problem to 2-SAT without thinking too much.

An interesting application of this idea is a way to find all vertices that must lie in the optimal vertex cover. In terms of 2-SAT, we just want to find out for every variable whether its value is the same for any valid assignment. Clearly, if x is reachable from not-x, then x has to be 1. One can also show that in case when neither x nor not-x is reachable from one another, the value of x can be set arbitrarily.

A downside of this method is that in works in O(n2), where n is the number of variables, since we need to run n independent DFS's. One can optimize this to O(n2 / 32) by compressing strongly connected components and run DFS on DAG with bitsets. However, if the maximum matching is not given beforehand, we don't lose in terms of time complexity, as we first need to find M itself.

Hope this idea will be helpful one day (it was for me).

Bonus: can this idea be applied for determining for every vertex whether is can belong to some optimal vertex cover?

Full text and comments »

  • Vote: I like it
  • +84
  • Vote: I do not like it

By irkstepanov, 10 years ago, translation, In English

On the 10th of July another international olympiad has ended. The 21st "Tuymaada" in mathematics, physics, chemistry and informatics took place in Yakutsk, Russia. Here's a link for statements and tests. Naturally, this is informatics:) The first day consisted of 5 problems whilst the second had only three. Each day lasted for five hours.

UPD. Now, thanks to Fefer_Ivan, it is possible to solve these problems on Codeforces, in gyms. However, there is only the first day available. I would be grateful if any of the participants could send me the solution book (electronic version), which were given on the closing ceremony.

UPD2. Some users prefer using .pdf to .doc. You can find .pdf files here.

Full text and comments »

  • Vote: I like it
  • +14
  • Vote: I do not like it