Let be a geometric set system, also called a range space, where is a set of points and each is a subset of , also called a range. We are primarily interested in range spaces defined by a set of points in two dimensions and ranges defined by axis-aligned rectangles. We say that a point is exposed if no range in contains . The max-exposure problem is defined as follows: given a range space and an integer parameter , remove ranges from so that a maximum number of points are exposed. That is, we want to find a subfamily with , so that the number of exposed points in the (reduced) range space is maximized.
The max-exposure problem arises naturally in many geometric coverage settings. For instance, if points are the location of clients in the two-dimensional plane, and ranges correspond to coverage areas of facilities, then exposed points are those not covered by any facility. The max-exposure problem in this case gives a worst-case bound on the number of clients that can be exposed if an adversary disables facilities. Similarly, in distributed sensor networks, ranges correspond to sensing zones, points correspond to physical assets being monitored by the network, and the max-exposure problem computes the number of assets exposed when sensors are compromised.
More broadly, the max-exposure problem is related to the densest -subgraph problem in hypergraphs. In the densest -subhypergraph problem, we are given a hypergraph , and we want to find a set of vertices with a maximum number of induced hyperedges. In general hypergraphs, finding -densest subgraphs is known to be (conditionally) hard to approximate within a factor of , where is the number of vertices. The max-exposure problem is equivalent to the densest -subhypergraph problem on a dual hypergraph, whose vertices corresponds to the ranges , and whose hyperedges correspond to the set of points . Specifically, each point corresponds to a hyperedge adjacent to the set of ranges containing the point . In the rest of the paper, we will use for the number of ranges in and for the number of points. We show that if the range space is defined by convex polygons, then the max-exposure problem is just as hard as the densest -subhypergraph problem. However, for ranges defined by axis-aligned rectangles, one can achieve better approximation. In particular, we obtain the following results.
We show that the max-exposure problem is NP-hard and assuming the dense vs random conjecture , it is also hard to approximate better than a factor of even if the range space is defined by only two types of rectangles in the plane. For range space defined by convex polygons, we show that max-exposure is equivalent to densest -subhypergraph problem, which is hard to approximate within a factor of .
When ranges are defined by translates of a single rectangle, we give a polynomial-time approximation scheme (PTAS) for max-exposure. The PTAS stands in sharp contrast to the inapproximability of ranges defined by two types of rectangles. Moreover, as an easy consequence of this result, we obtain a constant approximation when the ratio of longest and smallest side of rectangles in is bounded by a constant. However, we do not know if max-exposure with translates of a single rectangle can be solved in polynomial time or is NP-hard.
For ranges defined by arbitrary rectangles, we present a simple greedy algorithm that achieves a bicriteria -approximation. That is, if the optimal number of points exposed is , the algorithm picks a subset of rectangles such that the number of points exposed is at least , for some constant . No such approximation is possible for general hypergraphs. If rectangles in have a bounded aspect ratio, the approximation improves to . For pseudodisks with bounded-ply (no point in the plane is contained in more than a constant number of ranges), this algorithm achieves a constant approximation.
The PTAS is obtained by first optimally solving a restricted max-exposure instance where all points are contained in a unit square using dynamic programming in polynomial time. Next, we carefully combine them to obtain an optimal solution in time for the case when input points lie in a square. Applying well known shifting techniques on this gives us the PTAS. Both bicriteria algorithms are obtained by carefully assigning the points to ranges and applying greedy strategies.
Coverage and exposure problems have been widely studied in geometry and graphs. In the classical set cover problem, we want to select a subfamily of sets that cover the maximum number of items (points) [16, 17]. For the set cover problem, the classical greedy algorithm achieves a factor approximation for the number of sets needed to cover all the items, or factor approximation for the number of items covered by using exactly sets. Similarly, in geometry, the art gallery problems explore coverage of polygons using a minimum number of guards. Unlike coverage problems where greedy algorithms deliver reasonably good approximation, the exposure problems turn out to be much harder. Specifically, choosing sets whose union is of minimum size is much harder to approximate with a conditional inapproximability of where is the number of elements, or where is the number of sets . This so-called min-union problem is essentially the complement of the densest -subhypergraph problem on hypergraphs . The densest -subgraph problem for graphs has a long history [14, 3, 2, 6]. The paper  also studies the special case of an interval hypergraph , whose vertices is a finite subset of and for each edge there are values such that . That is, vertices are integer points and edges are intervals containing them. They show that this restricted case can be solved in polynomial time. The corresponding max exposure instance is when ranges are intervals on the real line. As discussed later, this 1-D case can also be solved in polynomial time. Moreover, we show that good approximations can also be obtained for some geometric objects in two dimensions.
The coverage problems have also been studied for geometric set systems where improved approximation bounds are possible using the dimension [1, 7, 21]. Multi-cover variants, where each input point must be covered by more than one set, are studied in [8, 12]. The geometric constraint removal problem [4, 13], where given a set of ranges, the goal is to expose a path between two given points by deleting at most ranges (a path is exposed if it lies in the exterior of all ranges), is also closely related to the max-exposure problem. Even for simple shapes such as unit disks (or unit squares) [5, 19], no PTAS is known for this problem.
The remainder of the paper is organized as follows. In Section 2, we discuss our hardness results followed by the bicriteria -approximation in Section 3. In Section 4, we study the case when consists of translates of a fixed rectangle and describe a PTAS for it. Finally, in Section 5, we use these ideas to obtain a bicriteria -approximation when the aspect ratio of rectangles in is bounded by a constant.
2 Hardness of Max-Exposure
We show that the max-exposure problem for geometric ranges is both NP-hard, and inapproximable. We begin by reducing the densest -subgraph on bipartite graphs (bipartite-DkS) to the max-exposure problem; the known NP-hardness of biparite-DkS then implies the hardness for max-exposure. Moreover, we show that bipartite-DkS is hard to approximate assuming the dense vs random conjecture, thereby establishing the inapproximability of max-exposure.
In the bipartite-DkS problem, we are given a bipartite graph , an integer , and we want to compute a set of vertices such that the induced subgraph on those vertices has the maximum number of edges. Given an instance of bipartite-DkS, we construct a max-exposure instance as follows.
Let be a thin vertical rectangle and be a thin horizontal rectangle. For each vertex , we create a copy of , and place it such that its lower-left corner is at . Similarly, for each vertex , we create a copy of , and place it such that its lower-left corner is at . These rectangles create a checkerboard arrangement, with cells of intersection. For each edge , we place a single point in the cell corresponding to intersection of and . It is now easy to see that has a -subgraph with edges if and only if we can expose points in this instance by removing rectangles: the removed rectangles are exactly the vertices chosen in the graph, and each exposed point corresponds to the edge included in the output subgraph. (See also Figure 2.) We will later make use of this reduction, and therefore state it as the following lemma.
The max-exposure problem is at least as hard as bipartite-DkS.
Since bipartite-DkS is known to be NP-hard , we have the following.
Max-exposure problem with axis-aligned rectangles is NP-hard.
2.1 Hardness of Approximation
The construction in the preceding proof shows that max-exposure with rectangles is at least as hard as bipartite-DkS problem. Moreover, the geometric construction uses translates of only two rectangles . In the following, we show that even with such a restricted range space, the problem is also hard to approximate. To that end we prove that bipartite-DkS cannot be approximated better than a factor , where is the number of vertices in this graph. More precisely, if the densest subgraph over vertices has edges, it is hard to find a subgraph over vertices that contains edges in polynomial time. This hardness of approximation is conditioned on the so-called dense vs random conjecture  stated as follows.
Given a graph , constants , and a parameter , we want to distinguish between the following two cases.
(Random) where , that is, has average degree approximately .
(Dense) is adversarially chosen so that the densest -subgraph of has average degree .
The conjecture states that for all , sufficiently small , and for all , one cannot distinguish between the dense and random cases in polynomial time (w.h.p), when .
In order to obtain hardness guarantees using the above conjecture, one needs to find the ‘distinguishing ratio’ , that is the least multiplicative gap between the optimum solution for the problem on the dense and random instances. If there exists an algorithm with an approximation factor significantly smaller than , then we would be able to use it to distinguish between the dense and random instances, thereby refuting the conjecture. We obtain the following result for densest -subgraph problem on bipartite graphs.
Assuming that dense vs random conjecture is true, the densest -subgraph problem on bipartite graphs is hard to approximate better than a factor of optimum.
Let be a graph sampled either from the dense or from the random instances. We construct a bipartite graph as follows. For every vertex , add a vertex to and to . For every edge , we add the pair of edges and to . That is, every edge is mapped to two copies and we define to be their parent edge as . Similarly, for a vertex and its two copies , we define . We say that is dense if the underlying graph was sampled from the dense case, otherwise we say that is random.
Consider a set of vertices in . If came from the dense case, there must be a set of vertices that have edges between them. So the number of edges in dense case . Otherwise, we are in the random case. Consider the optimal set of vertices that maximizes the set of edges in the induced subgraph . Now consider the corresponding set of vertices of the original graph and the set of edges in the induced subgraph . We have that and because for each edge , we will have the edge . Since and we are in the random case, we can upperbound the number of edges in as the number of edges in the densest subgraph of over vertices. This is w.h.p. where ignores logarithmic factors. Therefore the optimum number of edges in the random case is w.h.p.
Choosing , , , gives us w.h.p. and . If we could approximate this problem within a factor , then in the dense case, the number of edges computed by this approximation algorithm is which is strictly more than the maximum possible edges in the random case. Therefore, we would be able to distinguish between dense and random cases, and thereby refute the conjecture for these values of and . ∎
Using the same construction as in Lemma 1, we obtain the following.
Assuming the dense vs random conjecture, max-exposure with axis-aligned rectangles is hard to approximate better than factor of optimum.
2.2 Hardness of Max-exposure with Convex Polygons
We now show that the max-exposure problem is equivalent to the densest -subhypergraph problem for general hypergraphs when the range space is defined by convex polygons. In one direction, the max-exposure instance naturally corresponds to a hypergraph whose vertices are the ranges and the edges correspond to points and are defined by the containment relationship. Clearly, the densest -subhypergraph corresponds to the set of ranges deleting which exposes maximum number of points. For the other direction, we have the following lemma. (See also Figure 2.)
Given a hypergraph , one can construct a max-exposure instance with convex ranges and points such that the densest -subhypergraph of corresponds to a solution of max-exposure.
For each edge of the hypergraph, add a point . We place all the points of in convex position. Let be a vertex and be the set of hyperedges adjacent to . Since points in are in convex position, any subset of forms a convex polygon. Therefore, for every , we can draw a convex polygon whose corners are the point set corresponding to the hyperedges . The polygons will likely overlap in the convex region but for every point , the polygons containing are precisely the ones that have as its corner. Therefore, is exposed if and only if all vertices of the hyperedge are selected. ∎
3 A Bicriteria -approximation Algorithm
In this section, we present a simple approximation algorithm for the max-exposure problem that achieves bicriteria -approximation for range spaces defined by arbitrary axis-aligned rectangles. Specifically, if the optimal number of points exposed is , the algorithm picks a subset of rectangles such that the number of points exposed is at least , for some constant . In fact, the results hold for any polygonal range with complexity.
This bicriteria approximation should be contrasted with the fact that no such approximation is possible for the densest -subhypergraph problem: that is, one cannot compute a set of vertices for any constant such that the number of edges in the induced subhypergraph is at least optimal. Thus the geometric properties of the range space have a significant impact on the problem complexity. In particular, if consists of rectangle ranges, we show that the following strategy picks a subset of ranges such that the number of points exposed is at least , for a parameter and constant that will be fixed later. Choosing gives us the claimed bound.
Our algorithm is essentially greedy. We divide the points into maximal equivalence classes, where each class is the maximal subset of points belonging to the same subset of ranges. We define as the set of ranges that contain a point , and remove all points that are contained in more than ranges, since they can be never exposed in the optimal solution. Therefore, without loss of generality, we can assume that for all points . The rest of the algorithms is as follows.
In Algorithm 1, observe that every point in the th group is contained in the same set of ranges, which we denote by . Moreover, we have . Therefore, the total number of ranges that we delete in Step 2 is at most . It remains to show that the number of points exposed is at least .
Let be the number of points exposed by the algorithm Greedy-Bicriteria, and let be the optimal number of exposed points, Then, .
Consider the optimal set of ranges that are deleted, and let be the set of exposed points. We partition the set of points into groups as before, such that each group is identified by the range set , for any . Since , we must have that . This holds because for every group there must be a group such that . Moreover since is the maximum set of points that can be exposed, we must have that . Finally, we note that the number of groups is bounded by the number of cells in the arrangement of ranges in which is at most for some fixed constant , for all -complexity ranges. If the groups in are arranged by decreasing order of their sizes, we have that
The parameter can be tuned to improve the approximation guarantee with respect to one criterion (say the number of exposed points) at the cost of other. With , the algorithm exposes at least by removing ranges. As for the running time, a simple implementation of the algorithm can be made to run in time: we can build the point-range containment relation in time, partitioning the point set into groups takes an additional time.
3.1 Constant Approximation for Pseudodisks with Bounded-ply
If the range space consists of pseudodisks of bounded-ply (no point in the plane is contained in more than a constant number pseudodisks), then the algorithm Greedy-Bicriteria achieves a constant approximation. Due to the bounded-ply restriction, we have that the number of pseudodisks containing the points of group is , and therefore number of pseudodisks that are removed in Step 2 of the algorithm is also at most . Moreover, the number of cells in an arrangement of pseudodisks with depth at most is . Therefore, we can bound the number of groups of the optimal solution in the proof for Lemma 4 to be at most . This gives us that the number of points exposed , where is the number of points exposed by the optimal solution.
If the range space consists of pseudodisks of bounded-ply , then algorithm Greedy-Bicriteria exposes at least points by deleting at most pseudodisks, where .
Choosing , the algorithm achieves a bicriteria -approximation. With , the algorithm exposes at least fraction of the optimal number of points by deleting ranges.
4 A PTAS for Unit Square Ranges
We have seen that max-exposure is hard to approximate even if the ranges are translates of two types of rectangles. We now describe an approximation scheme when the ranges are translates of a single rectangle. In this case, we can scale the axes so that the rectangle becomes a unit square without changing any point-rectangle containment. Therefore, we can assume that our ranges are all unit squares. The problem is non-trivial even for unit square ranges, and as a warmup we first solve the following special case: all the points lie inside a unit square. We develop a dynamic programming algorithm to solve this case exactly, and then use it to design an approximation for the general set of points.
4.1 Exact Solution in a Unit Square
We are given a max-exposure instance consisting of unit square ranges and a set of points in a unit square . Without loss of generality, we can assume that the lower left corner of lies at origin and all ranges in intersect
. We classify the ranges into be one of the two types: (See also Figure 4).
Type-0: Unit square ranges that intersect .
Type-1: Unit square ranges that intersect .
(A unit square range coincident with both and is assumed to be Type-0). We draw two parallel horizontal lines and coincident with bottom and top horizontal sides of respectively. We say that a range is anchored to a line if it intersects . Note that every is anchored to exactly one of or . (When is coincident with both and , we say that it is anchored to ).
Moreover, for the rest of our discussion, let be a vertical line and define to be the set of points that have -coordinate at least . In other words, is the set of active points at . Similarly, define to be the set of active ranges that have at least one corner to the right of . That is, either intersects or lies completely to the right of it.
In order to gain some intuition, we will first consider the following two natural dynamic programming formulations for the problem.
Suppose that the points in are ordered by their increasing -coordinates and let be the -coordinate of the th point . We define a subproblem as which represents the maximum number of points in that can be exposed by removing ranges from the range set . If we define , then gives the optimal number of exposed points for our problem.
Let be the number of new ranges in that contain . Then, we can can express the subproblems at in terms of subproblems at as follows.
Roughly speaking, at which is the event corresponding to a point , we have two choices : expose or do not expose . If we expose , we pay for deleting the ranges in that contain and mark them as deleted by adding to the deleted range set . It is easy to see that this correctly computes the optimal number of exposed points since we charge for every deletion exactly once. However, there is one complication: a priori it is not clear how to bound the number of range subset used by this dynamic program. We later argue that the geometry of range space for Type-0 ranges allows us to use only a polynomial number of choices.
An alternative approach is to consider both point and begin-range events. That is, is either incident to a point or to the left vertical side of a range . Then, we can define a subproblem by the tuple which represents the maximum number of points in that can be exposed by removing ranges in . If we define , then gives the optimal number of exposed points. Let be the set of points contained in the range , then we have the following recurrence.
|(event was beginning of a range )|
|(otherwise, event was a point )|
In the above formulation, at each begin-range event for some , we have two choices: delete or do not delete . If was deleted, we reduce the budget by one. Otherwise, if was not deleted, we can never expose the points in , and therefore we add to the forbidden point set . The correctness of the dynamic program follows from the fact that for every point , all the ranges containing it must begin before , and we expose only if those ranges were deleted. Again, it is not obvious how many different subsets are needed by the dynamic program. However, we will later show that by keeping track of polynomial number of sets , we can solve max-exposure with Type-1 ranges.
We note that the Type-0 and Type-1 ranges may superficially seem symmetric but once we fix the order of computing subproblems, they become structurally different. Therefore, we would need slightly different techniques to handle each type. For the ease of exposition, we present dynamic programs for Type-0 and Type-1 ranges separately and finally combine them. Also note that if the ranges in are intervals on the real line (max exposure in 1D), then both DP-template-0 and DP-template-1 can be easily applied to obtain a polynomial time algorithm.
We will now define the following ordering relations that will be useful later. Let be a horizontal line, and let denote the orthogonal distance of from . If are two points, we say that is closer to than if . Similarly, for a range that is anchored to , let be the vertical distance inside the unit square between and the side of parallel to . If are two ranges, we say that is closer (or equivalently is farther) from if both are anchored to and . (See Figure 4.)
4.1.1 Max-exposure with Type-0 Ranges
Recall that Type-0 ranges intersect the vertical lines and are anchored to either or . We will apply the formulation discussed in DP-template-0. The key challenge here is to bound the number of possible deleted range sets . Towards that end, we make the following claim. Recall that is the set of active ranges at .
Let be the two exposed points strictly to the left of that are closest to and respectively. Then our dynamic program only needs to consider the set of deleted ranges at conditioned on .
Observe that since consists of Type-0 ranges, every range in must intersect the vertical line . Suppose we partition into ranges that are anchored to and that are anchored to . Let be the set of all exposed points strictly to the left of . Observe that for all , any range that contains must also contain . Therefore, we must have , for all . Similarly, , for all . This gives us . Therefore, the set consists of all the active ranges that contain at least one exposed point and were therefore deleted to the left of . ∎
Therefore, if our dynamic program remembers the exposed points , then we can compute the deleted range set at . There are choices for the pair , so the number of possible sets is also . We can therefore identify our subproblems by the tuple which represents the maximum number of exposed points with -coordinates or higher using rectangles from the set . With , we obtain the following recurrence:
where the function returns whichever of is closer to , and returns whichever of is closer to . The optimal solution is given by , where and are two artificial points with (not contained in any range). The base case is defined by the rightmost event at vertical line and is initialized with zeroes for all and . Any subproblem with has value .
4.1.2 Max-exposure with Type-1 Ranges
Next we consider the case when we only have Type-1 ranges in . Unfortunately in this case, our previous dynamic program does not work and we need to remember a different set of parameters. More precisely, we will apply the formulation discussed in DP-template-1, and bound the number of possible forbidden point sets . Recall that is the set of active points at (with -coordinate or higher).
Let be two ranges that begin to the left of and were not deleted. Moreover, is anchored to and is farthest from . Similarly is anchored to and is farthest from (Figure 6). Then the forbidden point set at is given by , where is the set of points contained in range .
Recall that the set consists of ranges that have at least one corner to the right of the vertical line . Since we are dealing with Type-1 ranges, every range that begins to the left of lies in . Now let be the set of ranges that begin to the left of and were not deleted. Here is the set of points in that have -coordinate or higher. Now consider any range . Recall that must be anchored to either or . If was anchored to , then every point of that lies in also lies in . Otherwise was anchored to , so every point of that lies in also lies in . Therefore, , which is precisely the forbidden point set . ∎
Therefore, if our dynamic program remembers the ranges and , we can compute the forbidden point set at . Since there are choices for the pair , the number of possible sets is also . We can now identify the subproblems by the tuple which represents the maximum number of points in that are exposed by deleting ranges that begin on or after . This gives us the following recurrence.
|(event was beginning of a range )|
|(otherwise, event was a point )|
Here, the function farther simply updates the ranges with if needed. More precisely, if is anchored to and is farther from than , then returns , otherwise it returns . Similarly, if is anchored to , and is farther from than , then returns , otherwise it returns .
The optimal solution is given by , where are two artificial ranges of zero-width : is anchored to and is defined by corners and ; similarly, is anchored to and is defined by corners and .
We note that remembering a constant number of exposed points (DP-template-0) or a constant number of undeleted ranges (DP-template-1) by themselves cannot solve both Type-0 and Type-1 ranges. For instance, in Figure 6(a) with Type-0 ranges, if were both not deleted but we remembered one of them, then we will incorrectly expose one of . Similarly in Figure 6(b) with Type-1 ranges, if were both exposed but we only remembered one of them, we will pay for one of the ranges again when we expose . However, since both the dynamic programs for Type-0 and Type-1 ranges express subproblems at event in terms of subproblems at event , we can easily combine them with minor adjustments.
|ranges containing point|
|points contained in range|
|exposed points closest to|
|undeleted ranges farthest from|
|points with -coordinate at least (active points)|
|ranges with at least one corner to the right of (active ranges)|
|subset of that are Type-0 (active Type-0 ranges at )|
|forbidden point set given by|
|deleted range set given by|
4.1.3 Combining them together
In the following, we will combine the dynamic programs for Type-0 and Type-1 ranges to obtain a dynamic program for max-exposure in a unit square . We will need a couple of changes. First, the events at are now defined by either a point or beginning of a Type-1 range . Next, the deleted range set at will only consist of Type-0 ranges and is defined as where is the set of Type-0 ranges that intersect the vertical line . The forbidden point set stays the same. Here are same as defined before. (For the sake of convenience, Table 1 lists these notations with explanation.)
The subproblems represent the maximum number of points in that can be exposed by deleting ranges from . If , then we obtain the following combined recurrence.
|(event was a point )|
|(event was beginning of a Type-1 range )|
The optimal solution is given by . The correctness of the above formulation follows from the fact that when we choose to expose , we are guaranteed that all Type-1 ranges in have already been deleted, and the expression only charges for Type-0 ranges containing . As for the running time, for each event , we compute entries and computing each entry takes constant time. Since there are events, we obtain the following.
Given a set of points in a unit square and a set of unit square ranges , we can compute their max-exposure in time.
4.2 A Constant Factor Approximation
We now use the preceding algorithm to solve the max-exposure problem for general set of points and unit square ranges within a factor of optimum. In particular, we compute a set of ranges in such that the number of points exposed in by deleting them is at least the optimal number of points. Suppose we embed the ranges on a uniform unit-sized grid , and define as the collection of all cells in that contain at least one point of . Then we can solve exactly for each cell in and combine them using dynamic programming as described in Algorithm 2 (DP-Approx). See also Figure 7.
Apply Lemma 8 to solve max-exposure locally in every cell for all . Call this a local solution denoted by , where is the set of points contained in cell and is the set of ranges intersecting .
Process cells in in any order , and define as the maximum number of points exposed in the cells through using ranges. Combine local solutions to obtain as follows.
Return as the number of exposed points.
If is the optimal set of exposed points, then , that is , the algorithm DP-Approx achieves a -approximation and runs in time.
Consider the optimal set of ranges . Observe that each range intersects at most four grid cells. Let be the rectangular region defined by intersection of and . Clearly, there are at most four regions for each and therefore in total. At this point, the regions in cell are disjoint from regions in some other cell . Therefore, optimal solution exposes points over a set of cells such that the set has at most disjoint components in the cells . Since we can solve the problem exactly for each cell and can combine them using the above dynamic program, we have that and we achieve a -approximation.
For the running time, we observe that solving max-exposure locally in a cell takes time, where is the number of ranges that intersect and is the number of points in that lie in . Summed over all cells, we get the following bound.
Once the local solutions are computed, the dynamic program that merges them into a global solution has subproblems and computing each subproblem takes time. Recall that every cell in contains at least one point, so and the merge step takes an additional time. ∎
4.3 Towards a PTAS
In this section, we will show how to extend the exact algorithm for the restricted max-exposure instance where all points lie inside a unit square (Lemma 8) to obtain an exact solution for the max-exposure instance where all points are contained in a square . Without loss of generality, we can assume that the lower left corner of is at the origin and is subdivided into unit-sized grid cells.
Observe that a major hurdle in generalizing the dynamic program from Section 4.1 for max-exposure in a unit square cell to the grid is that a range can be double counted in multiple cells. Specifically, range may contain exposed points in at most four cells of and can be counted in each one of them. (See also Figure 8.) Indeed a natural generalization of the earlier dynamic program to anchor lines avoids double counting of ranges in the same column of (vertical neighbors). However, some additional work is required to avoid double counting in adjacent columns (horizontal and diagonal neighbors).
To handle this, we first apply the following transformation which we call flattening of the grid .
Flattening the grid
Intuitively, the flattening process transforms a grid into a vertical slab by shifting the -th column and aligning it on top of the -th column. More precisely, we label the cells column by column from left to right and bottom to top in each column. That is, cells of the column are labeled as and the cells of column are labeled and so on. Then, flattening refers to simply stacking all the cells in their numbered order. In other words, we shift the coordinates of all points and parts of ranges in column of the grid by , for all . (See also Figure 9.)
After this transformation, all -coordinates are within the range and -coordinates are within the range . Moreover, every range is split into two possibly disconnected half-ranges which preserve the following important property that follows readily from the fact that the ranges are unit squares.
Let be a range and