4.2 Maximal cliques regarding parameter t Let t be the hypotenuse of the lowest semi-square in the cliques, and let r (t) denote the whole square defined by the diagonal t. Note that it makes sense to use t in the two different but related contexts. Using the same notation as in [9], P(t) denotes the set of semi-squares that include the left endpoint of t, Q(t) is the set of semi-squares that include t's right endpoint, and R (t) denotes the set of semi-squares that intersect t but include none of its endpoints. Ps(t), Qs(t), and Rs(t) denote the set of the full squares corresponding to the set of semi-squares P(t), Q(t) and R (t), while more importantly, we will consider the sets Pr(t), Qr(t) and Rr(t) which denote the set of rectangles given by the intersection of r (t) with each single element of Ps(t), Qs(t) and Rs(t). Note that the left upper corner of r (t) is also the left upper corner for the rectangles in Pr(t), while the right lower corners are the same as that of the corresponding semi-squares in P(t). Similar facts hold for rectangles in Qr(t) and Rr(t). The following observation provides the idea to how to determine the maximal cliques with lowest semi-square r (t): Each point x ∈ r (t) is overlapped by a set of rectangles from Pr(t) ⋃ Qr(t) ⋃ Rr(t). The crucial observation is that their corresponding semi-squares are also pairwise intersecting, so x ∈ r (t) denotes a clique of semi-squares. This is important, because we state here that in the restriction to r (t) we have an equivalence between the intersection of the rectangles and the intersection of the semi-squares. Thus, the question to finding maximal cliques in the c-max-tolerance graph is now reduced to finding an area where a maximal set of rectangles intersects. The points intersected by the same set of rectangles form simple orthogonal connected polygons p. Each such polygon p is also characterized by the cardinality of this set which we call cover (p). Polygonal regions p' adjacent to p have either an additional intersection by another rectangle or one intersection missing. So the cover-variables of adjacent polygons differ by exactly 1 (see Fig. 6). If all adjacent polygons have a lower cover-parameter than cover (p), p denotes a maximal clique. We call p locally maximal in this case. Figure 6 Computing the maximal cliques regarding the hypotenuse t by intersection r (t) with Pr(t),Qr(t) and Rr(t). In the example, we have two rectangles from Pr(t), two from Rr(t) and one from Q(t). The numbers denote the cover-values of the corresponding polygons. Lemma 3 Locally maximal polygons in r (t) exactly determine the maximal cliques with lowest hypotenuse t. The algorithm We perform a left-to-right sweep. As the underlying data structure we keep the list L of all polygons which are currently intersected by the sweepline as well as a distinct list LM of all locally maximal polygons. We start our sweep at the left side of r (t) initializing list L by the polygons defined by all rectangles of Pr(t) in increasing order of their lower boundaries. LM is initialized with the topmost polygon representing the intersection of all rectangles in Pr(t). Two basic events occur while sweeping from left to right: 1. A rectangle from Pr(t) ends 2. A rectangle from Qr(t) or Rr(t) is added. 1. Let s be the rectangle from Pr(t) with the right lower corner c that ends. Since s intersects all polygons from c up to the upper boundary or r (t), the removal of s decreases the cover-variables by one for all polygons above c, the two polygons adjacent to c have to join, and the maximal polygons above c have to be output. The join-operation can be done by updating list L after locating the two polygons by binary search for c. The output operation can be performed easily by scanning list LM from the top until the y-coordinate of c has been reached. Note that there will not arise any new local maxima, and all previous maxima remain. One important speciality is that the maxima we just output should not be output even they still represent maxima. We call them false maxima, we remove them from the list LM and insert them in a list LF ordered by their y-coordinates. Note that false maxima have to be reinserted into list LM again as soon as they are covered by a new rectangle from either Qr(t) or Rr(t). This might happen as described in the next case: 2. A rectangle s from Qr(t) ⋃ Rr(t) starts to be intersected by the sweepline. We discuss the case that s ∈ Qr(t), the other case is symmetrical. Let c be the left upper corner of rectangle s. s adds a new intersection to all polygons below c, the polygon containing c is split into two and the cover-variables of all of them increase by one. Note that a new locally maximal polygon might arise below c. All false maxima below c become 'true' maxima again. They are deleted from LF and inserted again into LM. The operation can be performed by locating the polygon to be split by binary search in L, scanning the list LF until the y-coordinate of c is reached, and inserting all false maxima back into LM. Analysis: At each event we have to perform a binary search for corner c. A direct implementation includes the insertion and deletion of maxima and false maxima into the corresponding lists in time O(log n). Finally it leads to a runtime of O(n log n + C(t) log n + out), where C(t) denotes the number of maximal cliques with lowest hypotenuse t. Next we will show how to improve the efficiency of the algorithm to O(n log n + out): Instead of two separated lists LM and LF we keep only one doubly linked list LD of interleaved blocks containing false maximals and 'true' maximals ordered by y-coordinates. A block denotes a maximal sequence of maxima of one or the other kind. We keep also the blocks internally connected. Each block is created by a certain event and it will be removed eventually. We count only the number of block creations, which naturally links the number of block removals, and show that only O(n + C(t)) blocks will be created. One possible event is the creation/removal of a polygon adjacent to corner c of a single maximum in the list LD. Possibly one new block is created by splitting an old block into two. After having located the position of the block, corresponding to the y-coordinate of c, by binary search, this can be done in constant time. Clearly there are at most O(n) such events. All other events consist of browsing through the lists of blocks starting from the upper or lower boundary of rectangle r (t), output the contents and join adjacent blocks until reaching the polygon with y-coordinate of corner c. Hence in these events, each operation creates one or two new blocks, but might remove k blocks in time O(k). In total, we are using only time O(n log n) time. Lemma 4 Determining the maximal cliques with lowest parameter t takes time O(n log n + out).