Consider the Steiner Tree problem:
Problem: Steiner Tree
Input: a graph , a set of terminals , and an integer .
Output: Does contain a connected subset of size that contains all of ?
Without the connectivity requirement, this problem can easily be solved by standard DP techniques (although it is also trivial: Just output yes if and only if ). When trying to formulate a treewidth-based DP for the full problem, however, we run into an issue: A naive formulation might look as follows:
with many states. This does not quite work, however: consider a grid graph like the following:
Here, tells us nothing about whether and are connected somewhere within (ie. through ) or outside (through ). Subsequently we will not be able to ensure that and are connected at all!
The βsimpleβ way to work around this is to represent which subsets of are connected in directly in the DP state itself, ie.
And while this works (and leads to a running time of the form ), the dependence on the treewidth is no longer singly exponential.
The Cut&Count technique [3] is a recent (2013) technique invented to solve problems with βconnectivity constraintsβ such as the above in singly-exponential time.
It will turn out that, instead of finding an exact answer, it will be sufficient to count the number of solutions (of a slightly modified problem) modulo 2. (proof of this comes later). As is usual whenever a DP gets too complicated, we will also take the solution size as a parameter instead of computing the optimum directly.
Let be the set of all βsolutionsβ of the given size without the conΒnectivity constraint (we will call these βpotential solutionsβ), and be the subset of potential solutions which are actually connected.
We would like to compute mod 2, but this seems hard. Computing the parity of is easy (in fact computing the whole of is easy), but this will not be very useful as the parity of and may differ.1
The main idea of the Cut&Count technique is to replace the βglobalβ connectivity constraint with a local constraint about graph cuts. More specifically, consider some potential solution . Let a βconsistent cutβ of be a cut such that no edge in crosses the cut. EquiΒvalently, a consistent cut consists of an assignment of a side (βleftβ or βrightβ) to each connected component of , and thus the number of consistent cuts is exactly , where is the number of conΒnected components in .
This is almost what we want: if we somehow halved this number, we would get a number which is odd if is connected and even otherwise. So let
Then , since connected potential solutions2 contribute by exactly to all other potential solutions contribute by .
To halve this number, we may simply pick a vertex we know is in the solution (ie. any vertex in ) and require that it be put on the left side of the cut.
To compute we may use standard DP techniques: Given a bag , a subset and an assignment , let be the number of pairs in except restricted to such that and gives the side of each vertex in in the cut, requiring that . Computing in time should then be relatively straightforward.
The following definition and lemma are taken from [3]:
Definition. A function isolates a set family if there is a unique with .
Lemma. (Isolation Lemma, [4]) Let be a set family over a universe with . For each , choose a weight uniformly and independently at random. Then
The relevance of the Isolation Lemma is as follows: Let and be the set of solutions. Then the isolation lemma implies that if we randomly weigh the vertices in the graph, whp. there will be some weight such that exactly one solution has weight . In particular, is odd, so if we only look for solutions of weight , if , we will detect that we have an odd number of solutions and thus that a solution exists.
We get the following algorithm: let , and uniformly and independently at random assign a weight in to each vertex in the graph. Then, for each from to 3, compute the number of solutions of total weight . If any of them is nonzero, return True, otherwise return False.
Obviously, if the algorithm returns True, there must be at least one solution. Otherwise, the probability that a solution exists is , by the Isolation Lemma, as outlined above.