On Partitioning Grids into Equal Parts S.L. Bezrukov, B. Rovan
Department of Math. and Comp. Sci. University of Paderborn D-33095 Paderborn, Germany Abstract Let an edge cut partitions the vertex set of an n-dimensional quadratic grid with the side length a into k subsets A1 ; :::; Ak with jjAi j ? jAj jj 1. We consider the problem of determining thep minimal size c(n; k; a) of such a cut and present its asymptotic c(n; k; a) nan?1 k as a; k ! 1 and k=an ! 0. The same asymptotic holds for partitioning of the n-dimensional torus. We present also some heuristics, which provide better partitioning for n = 2 and small k. n
1 Introduction Various aspects of graph partitioning are of a particular interest in Theoretical Computer Science and arise in various applications. In our paper we study partitioning of grids { one of graphs which quite naturally appear in numerical computations, for example. Application of the nite elements method for solving dierential equations requires to partition the underlying area into simple gures - e.g. squares - and assign the nodes of the partition to the processors of a parallel computing system. Thus one comes to the problem of constructing the assignment so that the total amount of computations would be equally distributed among the processors and the information ow between the processors to be minimized. In other words one has to partition the vertex set of the underlying partition graph into a certain number of parts (corresponding to the number of processors in the system) consisting of equal number of vertices so, that the number of edges connecting the vertices of dierent parts is as minimal as possible. Graph partitioning problems are wide studied in the literature. Many papers are devoted to partitioning of arbitrary graphs (e.g. [5, 6, 7]) and analysis of complexity of partition problems. However, partitioning of some special graph classes often arising in practise are still not satisfactory studied. Relatively many papers are devoted to partitioning of graphs into two parts and computing the bisection width of such graphs, while the general case concerning the partitioning into more parts remains open. This work was partially supported by the German Research Association (DFG) within the SFB 376 \Massive Parallelitat: Algorithmen, Entwurfsmethoden, Anwendungen".
1
of grids into 2 parts were studied e.g. in [1, 3]. The paper [9] contains a number of another interesting results concerning partitioning of low-dimensional grids. Tori and their partitioning were studied in [4, 8], where the lower bounds are presented. The paper [2] deals with k-partitioning of the hypercube and contains some asymptotically optimal results for some particular series of k. In our paper we study k-partitioning of n-dimensional a a grids. Denoting the vertex set of such a grid via Gn , our problem is to construct for a given k a partition of the set Gn into k parts A1; :::; Ak with jjAij ? jAj jj 1. In other words an an (1) k jAij k ; i = 1; :::; k: For such a partition A = fA1; :::; Akg denote
rA = f(u; v) j u 2 Ai; v 2 Aj ; i 6= j g; i.e. rA is the set of cutting edges in the partition A. We say that a partition A is optimal if jrAj is minimal possible and denote by r(n; k; a) the size of an optimal partition. We deal with the problem of nding the asymptotic of r(n; k; a) with n xed and a; k ! 1. Our construction used in the proof of the upper bound provides a good partitioning
when k is relatively large. For n = 2 we also present some heuristics, which for small k work better than the general construction. The paper is organized as follows. In the next section we introduce a continuous model for the partition problem and present an asymptotic for the continuous analog of the number of the cutting edges. These results are used in Section 3 to get the asymptotic of the minimal number of the cutting edges in the original discrete model. Section 4 is devoted to heuristics, which provide better results for the partitioning for small k. Some remarks conclude the paper in Section 5.
2 The continuous model We use the following continuous model for the partition problem. Let n 2 and replace the grid Gn by the a a continuous n-dimensional cube Qn and introduce the notion of rectilinear body of IRn. By such a body we mean a measured area bounded by the hyperplanes of IRn parallel to the hyperplanes xi = 0, i = 1; :::; n, which we call basic hyperplanes. For a rectilinear body B IRn denote by B its volume and by @B the volume of its boundary. The volume of B and the volume of its boundary are the continuous analogs of the number of vertices of a subset of Gn and the size of the edge cut separating a set of vertices from its complement in Gn respectively. We start with the well-known isoperimetric inequality for the rectilinear bodies (cf. [3]).
Lemma 1 Let n 2 and B IRn be a rectilinear body. Then @B 2n (B ) ? : n
n
1
In particular the cube with volume (B ) has minimal boundary.
2
(2)
1
k
a each and denote = fB1; :::; Bk g. Further denote by the volume of volume S @Bk. Clearly is the continuous analog of the number of the cutting edges. B 2 Consider a problem of nding a partition of Qn into k rectilinear bodies with volume a each, so that is minimal. Denote this minimal value of by `(n; k; a). k n
n
Theorem 1 It holds: nan?1
p p k ? 1 `(n; k; a) nan?1 k + cn ;
(3)
n
n
with some constant cn depending on n only. Proof. Consider rst the lower bound. Let = fB1; :::; Bkg be an optimal partition of Qn, and x be a point of the boundary of some Bi . Clearly, if x is also a boundary point of Qn, then it is a boundary point of no other body Bj in the partition, because each Bi is a rectilinear body. Otherwise, x is a common boundary point of exactly some two distinct bodies Bi and Bj . Therefore, k X i=1
By Lemma 1,
@Bi = @Qn + 2 = @Qn + 2 `(n; k; a):
(4)
@Bi 2n (Bi ) ?1 = 2n an?1 k? ?1 ; which after taking into consideration @Qn = 2nan?1 gives the lower bound in (3). To get the upper bound in (3), consider rst the case, when k = tn for some integer t 2. In this case one can partition each edge of Qn into t equal segments, which provides a partitioning of Qn into tn subcubes. This partition is optimal, because it reaches the lower bound in (3). Therefore, `(n; tn ; a) = nan?1(t ? 1). In the general case of k we use induction on n. In the case n = 1 we extend the de nition of the rectilinear body de ning it as the union of nondisjoint line segments. Furthermore for a partition of the line segment [0:a] into k rectilinear bodies de ne as the number of points separating the bodies. Then trivially holds: `(1; k; a) = k ? 1 and so c1 = ?1. Now assume that n 2 and k is large enough, i.e. k 2n . Represent k in the form k = tn + with 0 < < (t +1)n ? tn and t 2. Denote a0 = t t+ a t 0 0 n n and consider a a| {z a} a rectangle Q Q with volume t + a , containing the n?1 0 origin of Qn, and let Q00 = Qn n Q0. Clearly, Q00 is a a| {z a} (a ? a ) rectangle. n n
n
n
n
n
n
n
n?1
We partition the rectangle Q0 into tn rectilinear bodies of size an=k by dividing each its edge into t equal parts. To obtain the rest k ? tn = parts of the partition we make a special partition of the rectangle Q00 using the fact that the length of one its side a ? a0 = t + a is relatively small and, as we will see, even a simple partition of this rectangle does not aect on the asymptotic of `(n; k; a). One has n
`(n; k; a) 0 + 00 + an?1: 3
(5)
the partition 0 is a rectangle, one has 0 = an?2((n ? 1)a0 + a)(t ? 1) nan?1 t:
(6)
To construct the partition 00 of the rectangle Q00 we represent it as the cartesian product Q000 (a ? a0), where Q000 is the (n ? 1)-dimensional cube with the side length a. Take an optimal partition of the cube Q000 into parts of equal size and for each part Bi000 of this partition construct a rectilinear body Bi00 = Bi000 (a ? a0), i = 1; :::; . The collection of the rectilinear bodies fBi00g forms the partition 00 of Q00. Therefore, p 00 = (a ? a0) `(n ? 1; ; a) (a ? a0)(n ? 1)an?2 ?1 + cn?1 (7) by induction. Since the function =(tn + ) increases on and < (t + 1)n ? tn bntn?1 n , one has for some bn with bn n n=2 n n (8) a ? a0 = tn + a (t + 1)tn ? t a bnt a : From (7) and (8) it follows q b n (n ? 1) n?1 ? 1 00 n?1 b t a n + cn?1 cn a t p for some cn depending on n only, which satis es the recursion cn bn(n ? 1)( ?1 bn + cn?1) with c1 = ?1. Substituting this and (6) into (5) gives the upper bound in (3). 2 n
n
n
3 Minimizing the number of cutting edges Consider rst the 2-dimensional grids. In this mostly practical case we present rst a construction providing a better constant c2 for the continuous model than above, and after that show how this construction can be modi ed for partitioning the discrete grids. Similar arguments work in the higher-dimensional case as well.
Ci
G2 n G 0 ...
G0
...
Q0 Bi
Ai
a.
Ci b.
Fig. 1 4
2 a (cf. Fig. 1a) and partition it by Consider the subquad Q0 Q2 with side length t2t+ 2 the optimal way as above into t parts B1; :::; Bt2 of area t2a+2 = ak2 . To complete the partitioning of the whole quad Q2 we have to partition the region Q2 n Q0 into parts C1; :::; C of the same area. We make this partition as it is shown in Fig. 1a for the case of odd , where q t2the cutting lines are depicted by the thin lines. Notice that Ci > 2, where = 1 ? t2+ a. This proves the correctness of the whole construction. The partition in the case of even is quite similar and omitted. Taking into account 2t, one has s 2 s 2 t `(2; k; a) 2a t2 + (t ? 1) + ( ? 1) + 2a t2 t+ 0 s 1 p 2at + @1 ? 1 ? t2 + A a 2a k + 2 :
p
p
Here in the last inequality we used t k and 1 ? x 1 ? x for 0 x 1. Now let us return back to our original problem of partitioning of G2. The lower p bound (3) for the cardinality of the cut is still valid, and we rewrite it in the form 2a( k ? 1) r(2; k; a). Concerning the upper bound, it is impossible to separate the grid just by direct lines as in our construction in Theorem 1 in general, because a2 may be not divisible on k. Thus, the rectangles in our construction will contain steps. In any case, it is easily seen that the number of steps is O(k), if each part of the partition is large enough. This leads to the following theorem:
Theorem 2 It holds: as a; k ! 1 and k=a2 ! 0.
p r(2; k; a) 2a k;
(9)
Proof. We get the upper bound for r(2; k; a), using the above construction. However, the parts of the partition are not quads and rectangles in general and may contain steps of height 1. It is sucient to show that the number of such steps is O(k). Indeed, in this case we would have an upper bound
p
p p r(2; k; a) 2a( k + 1) + O(k) = 2a k(1 + o(1));
if k = o(a), which provides the asymptotic (9). We assume that k = t2 + with 0 < 2t and that k0 parts in our partition have cardinality m = ba2=kc for some k0 > 0 and the rest k1 = k ? k0 0 parts are of cardinality da2=ke = m + 1. We split the parts in the partition into 2 groups: the group A0 of t2 parts Ai and the group A00 of 0 parts Ci. Since t 2 then t2 2t > and so without loss of generality we assume that all the parts Ci have the same cardinality. First we construct the parts of the group A0. Let M = PA 2A0 jAij and let the number M be represented in the form M = b2 + r. Consider the set G0 G2 of cardinality M shown in Fig. 1b and split it into t parts of cardinality bM=tc or bM=tc +1 each. After that split i
5
of the set G0 into t2 parts, cardinality of each part is either m or m + 1 or m + 2. If there are parts of cardinality m +2, we take one vertex from such a set and assign it to arbitrary set of cardinality m. Clearly, the number of steps in the part A0 is O(t2) = O(k). Now split the vertex set G2 n G0 into parts of the same size as it is shown in Fig. 1b. Clearly, the total number of steps in all parts Ci is O() = O(k), which completes the proof. 2 Following similar arguments and using the construction of the upper bound in Theorem 1 one can ensure that the number of steps in partitioning of the n-dimensional grid Gn is O(nk), which in combination with (3) leads to the following result.
Theorem 3 It holds:
p r(n; k; a) nan?1 k; as n = const, a; k ! 1 and k=an ! 0. n
(10)
We leave checking of the omitted details to the reader.
4 Heuristics The basic idea is to make the decomposition by using a table of best known decompositions into smaller number of parts. It is expected to be used for decompositions into \small" p number of parts, i.e., in decompositions into k parts, where k 2 does not hold and the method from Section 2 does not give satisfactory results.
4.1 Basic assumptions We consider decomposition of a rectangle in a continuous case. In the discrete case
this amounts to the assumption that the length of each interval occurring in the construction is divisible into a required number of equal length subintervals. Each subpart is again a rectangle with the sides parallel to the sides of the original rectangle. (This re ects the intuition that lines parallel to the sides of the rectangle form shorter boundaries.)
The heuristics can still be used in the discrete case, producing a decomposition into parts whose sizes may dier by more than one. By replacing some straight line boarders by 'dogleg' boarders one can try to obtain a correct decomposition without increasing the length of the boarders too much.
4.2 Basic version The following is a simpli ed version of the heuristics, illustrating the basic idea. 6
the number of parts into which the rectangle is to be decomposed. (We assume a b.) Assumed: A precomputed table is known, giving the best known decomposition of x by y rectangles into l parts of equal size, 2 l k ? 1. In each case the total length of borders parallel to x and the total length of borders parallel to y is given. These give the cost of decomposition c(x; y; l). Due to the symmetry we can assume x y. Output: Decomposition of the a by b rectangle into k parts of equal size.
ALGORITHM 1: 1. For each i; 1 i k=2, do (a) Divide the rectangle a by b into two rectangles of the size a ( ki b) and a ( k?k i b) by a line parallel to a. (b) Use the table to get the best i-decomposition and the best (k ?i)-decomposition of the new rectangles. Make the x direction parallel to a or b, whichever gives smaller border size. Call the resulting cost ci(a; b; k). 2. Choose the smallest ci(a; b; k) and output the corresponding decomposition. We illustrate this by constructing a table for decomposing a square.
k = 2; (=1+1)
k = 3; (2+1)
k = 4; (2+2)
k = 5; (3+2)
c(x; y; 2) = x
c(x; y; 3) = x + 23 y
c(x; y; 4) = x + y
c(x; y; 5) = 53 x + y
k = 6; (4+2)
k = 7; (5+2)
k = 8; (6+2)
k = 9; (6+3)
31 y c(x; y ; 8) = 2x + 7 y c(x; y ; 9) = 2x + 2y c(x; y; 6) = 2x + y c(x; y; 7) = 2x + 21 4 Fig. 2
7
The above approach is rather simple minded. It does not take into account, that for various values of the ratio x=y dierent decompositions into k parts may be needed to obtain better results. Now we present a heuristic algorithm for constructing the 'table of best decompositions', that will take into account the values of x=y. In fact, we only present the algorithm for extending an existing table for decompositions into up to k ? 1 equal parts into a table giving decompositions into k equal parts. Input: An integer k and the table Tk?1 giving the best known decomposition of x by y
rectangles into l parts of equal size, 2 l k ? 1, depending on the ratio of x and y. In each case the total length of borders parallel to x and the total length of borders parallel to y is given. These give the cost of the decomposition c(x; y; l). Due to the symmetry we can assume x y. Output: The table Tk .
ALGORITHM 2:
For the sake of presentation we refer to the rectangle to be decomposed into k parts (new entry in the table) as an a by b rectangle, assuming a b. The rectangles in the existing table are referred to as x by y rectangles. 1. For each i; 1 i k=2, do (a) Divide the rectangle a by b into two rectangles of the size a ( ki b) and a ( k?k i b) by a line parallel to a. (b) Use the table to get all decompositions of each of the two rectangles obtained by placing each decomposition in both ways (x parallel to a and x parallel to b) for each interval for x=y in the table and each pairing of the i{decomposition and (k ? i){decomposition. (c) For each of the decompositions obtained compute the length of the border (the cost of decomposition) as a linear function in a and b and add to the list of potential decompositions. 2. Decompose the interval (0; 1] into subintervals for values of a=b using intersection points of the linear functions in the list of the potential decompositions. 3. Choose the best decomposition for each of the subintervals of (0; 1] and create the entry for k{decomposition in the table. We illustrate the above algorithm on the case where from a given T3 a T4 is constructed. The " and ! indicate the orientation of the decomposition from T3 used.
8
k = 2;
y
2 (0; 1]
c(x; y; 2) = x
k = 3;
y
2 (0; 3 ]
k = 4;
y
2 [ 3 ; 1]
c(x; y; 4) = x + 23 y
c(x; y; 3) = 2x Fig. 3
We have the following decompositions of a a b rectangle, following the Algorithm 2: Step 1, i = 1. 1 + 31 "
c(a; b; 4) = 3a
1 + 31 !
1 + 32 "
c(a; b; 4) = a + 23 b c(a; b; 4) = 2a + 21 b Fig. 4
1 + 32 !
c(a; b; 4) = 35 a + 34 b
Step 1, i = 2. We use the partition 2 ! and 2 ! (cf. the right partition in Fig. 5). The cases 2 " and 2 !; 2 ! and 2 "; and 2 " and 2 " clearly do not bring new decomposition type and we omit them here to save space. Step 2. The 'crossing points' giving the decomposition of the interval (0; 1] for the values of ab are 3 1 9 3 8 , 2 , 16 , and 4 . Step 3. The rst decomposition is the best in (0; 12 ] and the last in [ 21 ; 1]. Thus, the table T4 is obtained from T3 by appending the following entries:
9
k = 4;
y
2 (0; 2 ]
k = 4;
c(x; y; 3) = 3x
y
2 [ 2 ; 1]
c(x; y; 4) = x + y Fig. 5
5 Concluding remarks We studied k-partitioning of the n-dimensional quadratic grids and found asymptotic of the minimal number of cutting edges. We restrict ourselves by considering the most practical case when the dimension of the grid is xed. However, it would be also interesting to investigate the case when the dimension tends to in nity and a and k are xed. In this case one has similar diculties as in the partitioning of the hypercube [2] and some special constructions are required. We leave this problem for further consideration. The same method can be applied for partitioning of discrete tori (i.e. the cartesian product of cycles). The construction of the upper bound works in this case, one has only add j@Qnj = 2nan?1 to it, which does not aect to its asymptotic as n = const, a; k ! 1 and k=an ! 0. For the proof of the lower bound we also use similar arguments as in the proof of Theorem 1. Now instead of (4) we have k X i=1
@Bi = 2 = 2 `(n; k; a);
which leads to asymptotically the same lower bound under the assumptions above. Thus we have the following theorem:
Corollary 1 The size of an optimal k-partition of the n-dimensional a a tori is p n ? 1 k, as n = const, a; k ! 1 and k=an ! 0. asymptotically equal to na n
We have also presented some heuristics for grid partitioning, which work quite good when the number of parts k is small. In cases where k is a product of two integers m and n one can enlarge the set of potentially good decompositions by rst decomposing into m parts and than each of these parts into n parts in addition to the decompositions in step 1. The simple minded Basic solution can be easily extended to 3 and more dimensions. The improved version may need some more thought in order to divide the cases with various sizes of the edges in a nice way.
10
[1] Ahlswede R., Bezrukov S.L.: Edge isoperimetric theorems for integer point arrays. Appl. Math. Lett., 8 (1995), No. 2, 75{80. [2] Bezrukov S.L.: On k-partitioning the n-cube. Technical Report tr-rsfb-95-002, University of Paderborn, 1995. [3] Bollobas B., Leader I.: An isoperimetric inequality on the discrete torus. SIAM J. Appl. Math., 3 (1990), 32{37. [4] Bollobas B., Leader I.: Edge-isoperimetric inequalities in the grid. Combinatorica, 11 (1991), 299{314. [5] Diekmann R., Luling R., Monien B., Spraner C.: Combining Helpful Sets and Parallel Simulated Annealing for the Graph-Partitioning Problem. Int. J. Parallel Algorithms and Applications, (to appear). [6] Diekmann R., Meyer D., Monien B.: Parallel Decomposition of Unstructured FEMMeshes. In: Proc. of IRREGULAR'95, Springer LNCS 980 (1995), 199{215. [7] Liou K.P., Pothen A., Simon H.D.: Partitioning sparse matrices with eigenvectors of graphs. SIAM J. on Matrix Anal. and Appl., 11 (1990), 430{452. [8] Mao W., Nicol D.M.: On k-ary n-cubes: Theory and Applications. In: Proc. of IPPS'95. [9] Rolim J., Sykora O., Vrt'o I.: Optimal Cutwidth and Bisection Width of 2- and 3-Dimensional Meshes. In: Proc. of WG'95.
11