A Efficiet Algorithm for Graph Bisectio of Triagularizatios Gerold Jäger Departmet of Computer Sciece Washigto Uiversity Campus Box 1045 Oe Brookigs Drive St. Louis, Missouri 63130-4899, USA jaegerg@cse.wustl.edu Abstract. Graph bisectio is a elemetary problem i graph theory. We cosider the best kow experimetal algorithms ad itroduce a ew algorithm called Logest-Path-Algorithm. Applyig this algorithm to the cluster tree geeratio of hierarchical matrices, arisig for example i discretizatios of partial equatios, we show that this algorithm outperforms previous algorithms. Keywords. Graph bisectio, hierarchical matrices, triagularizatios. AMS Subject Classificatio. 05C85, 68Q25, 68W20. 1 Itroductio Let G = (V, E) be a udirected ad uweighted graph with V =. Geeralizig the stadard defiitio for odd we defie a bisectio as a partitio (X, Y ) of V with X = 2. The bisectio width is
defied as the miimum umber of edges betwee X ad Y amog all possible bisectios (X, Y ) ad MiBisectio is the NP-hard problem of fidig a bisectio with miimum bisectio width. Sara ad Vazirai [9] developed a polyomial-time algorithm approximatig the bisectio width by a factor of /2 ad showed that their algorithm does ot approximate it with a better factor. Feige, Krauthgamer, Nissim [2] improved the approximatio factor to log. For some classes we ca compute the bisectio width i polyomial time. Papadimitriou, Sideri [8] gave such a algorithm for grid graphs. Boppaa [1] gave a algorithm based o eigevalue computatio ad the ellipsoid algorithm, which is able to compute a lower boud for the bisectio width ad equals it for a radom class of graphs. We cosider some elemetary algorithms, as the Simple-Greedy- Algorithm, the Kerigha-Algorithm [7] ad the Radomized-Black- Holes-Algorithm [3]. Although oly less complexity results are kow about them, they give good experimetal results. I this paper, we itroduce a ew elemetary bisectio algorithm. We show that its complexity is equal or better tha the complexity of the previous algorithms. I experimets with plaar graphs it beats the kow algorithms ad fids optimal solutios. Our applicatio is the followig problem which is importat i may topics, e.g. solvig partial differetial equatios ad itegral equatios: Cosider high-dimesioal matrices, which are dese, but might have large rak. As additio, multiplicatio ad iversio of those matrices are expesive, they are represeted as hierarchical matrices (Hmatrices). The operatios applied to the hierarchical matrices give the exact results with a small error term, but with a almost liear complexity. The hierarchical matrices cosist of some blocks of differet size each havig small rak. The partitio of the hierarchical matrices is described by cluster trees ad ca be viewed as a graph (for details see [4], [5], [6]). Fidig a small bisectio width of this graph eables us to efficietly computig the above operatios. We apply the algorithms to the followig typical example. We partitio the matrices by triagularizatio, with refiig at differet places: uiform refiemet, refiemet at oe side, refiemet at all sides. 2
2 Previous Algorithms For the algorithms we eed the followig defiitio: Defiitio 1. Let G = (V, E) be a graph ad X, Y V with X Y = ad X Y = V. a) For x X deote with I(x) the ier costs, i.e. the umber of edges (x, z) E with z X \ {x}. Aalogously we defie I(y) for y Y. b) For x X deote with O(x) the outer costs, i.e. the umber of edges (x, z) E with z Y. Aalogously we defie O(y) for y Y. { 1, if (x, y) E c) For x X, y Y let ω(x, y) :=. 0, otherwise d) For x X, y Y let S(x, y) := O(x) I(x) + O(y) I(y) 2ω(x, y). 2.1 Simple-Greedy-Algorithm The followig elemetary algorithm starts with a radom bisectio ad swaps two vertices of differet sides of the bisectio obtaiig a better bisectio, util there is o improvemet by this method. As the ier costs become outer costs ad the outer costs become ier costs by swappig two vertices x, y, we get a improvemet, if ad oly if S(x, y) > 0. Algorithm 1 (Simple-Greedy) Iput Graph G = (V, E) with V =. 1 Choose a bisectio (X, Y ), uiformly at radom amog all possible bisectios. 2 Choose x X, y Y with S(x, y) > 0. 3 Swap vertices x ad y. 4 Repeat steps 2 ad 3, util there are o x X, y Y with S(x, y) > 0. Output Bisectio (X, Y ) As the bisectio width is smaller tha 2, the steps 2 ad 3 ca be executed at most 2 times. Sice i each executio of step 2 the value S(x, y) is computed at most times, it follows: 2 2 Remark 1. The Simple-Greedy-Algorithm eeds O( 4 ) steps. 3
2.2 Kerigha-Li-Algorithm The followig algorithm of Kerigha, Li [7] is a geeralizatio of the Simple-Greedy-Algorithm. We do some swaps, eve if there is o improvemet after the swaps, but there might be a later improvemet. Algorithm 2 (Kerigha, Li) Iput Graph G = (V, E) with V =. 1 Choose a bisectio (X, Y ), uiformly at radom amog all possible bisectios. 2 Copy (X, Y ) to (X, Y ). 3 Choose x X, y Y with maximum S(x, y) (it might be S(x, y) 0). 4 Swap vertices x ad y. 5 X := X \ {x}, Y := Y \ {y}. 6 Repeat steps 3 to 5, util X :=, Y :=. 7 Choose the bisectio (X, Y ) as the bisectio with miimum bisectio width amog all bisectios received after step 4. 8 Repeat steps 2 to 7, util we caot get ay improvemet by these steps. Output Bisectio (X, Y ) Istead of oe executio of the steps 2 ad 3 i the Simple-Greedy- Algorithm, we execute times the steps 3 to 5 of the Kerigha- 2 Li-Algorithm. So we obtai: Remark 2. The Kerigha-Li-Algorithm eeds O( 5 ) steps. 2.3 Radomized-Black-Holes-Algorithm The followig algorithm of Ferecz et al. [3] starts with two empty sets X, Y, called the black holes, ad alterately adds to both sets oe vertex, util we have a bisectio. 4
Algorithm 3 (Radomized-Black-Holes) Iput Graph G = (V, E) with V =. 1 X :=, Y :=. 2 Choose uiformly at radom a edge betwee V \{X Y } ad X ad add the correspodig vertex i V \ {X Y } to X. If there is o such edge, choose uiformly at radom a vertex amog all vertices i V \ {X Y } ad add it to X. 3 Do step 2 for Y. 4 Repeat steps 2 ad 3, util (X, Y ) is a bisectio. Output Bisectio (X, Y ) Sice i each executio of step 2 or 3 we have to test at most 2 edges ad the steps 2 or 3 are executed times, it follows: Remark 3. The Radomized-Black-Holes-Algorithm eeds O( 3 ) steps. 3 Logest-Path-Algorithm For plaar graphs, it is reasoable to partitio the vertices ito two classes, which are separated by oly oe lie. We should get such a separatio, if we start from two vertices with large distace. So we choose oe arbitrary vertex z. By repeatedly determiig the eighborhoods of z, we fid aother vertex x, as far as possible from z. After repeatig this process with x, we obtai y. We start with {x} ad {y} ad multiply add the eighborhoods to the previous sets, util we have a bisectio. Algorithm 4 (Logest-Path) Iput Graph G = (V, E) with V =. 1 Choose uiformly at radom a vertex z. 2 Z := {z}. 3 List all eighbors of vertices from Z ad add it to Z. 4 Repeat step 3, util Z = V. 5 Choose oe of the vertices, added i the last executio of step 3, ad deote it with x. 5
6 Repeat steps 2 to 5 with x istead of z. The resultig vertex is deoted with y. 7 X := {x}, Y := {y}. 8 List all eighbors of vertices from X ad add each eighbor to X, except for X 2. 9 Repeat step 8, if X < 2. 10 List all eighbors of vertices from Y ad add each eighbor to Y, except for Y 2. 11 Repeat step 10, if Y < 2. 12 Add the remaiig vertices i a arbitrary way, so that X = 2 ad Y = 2. Output Bisectio (X, Y ) As i the steps 3,8 ad 10 for every added vertex we have to test at most 2 edges, we obtai the same complexity as for the Radomized- Black-Holes-Algorithm: Remark 4. The Logest-Path-Algorithm eeds O( 3 ) steps. As the Simple-Greedy-Algorithm should reduce the legth of the lie separatig the two sides of the bisectio, we add this algorithm to the Logest-Path-Algorithm. I this case, for the Simple-Greedy- Algorithm it is sufficiet to test oly the vertices, which have at least oe eighbor at the other side of the bisectio. 4 Experimetal Results We have tested the Simple-Greedy-Algorithm (SG), the Kerigha- Li-Algorithm (KL), the Radomized-Black-Holes-Algorithm (RBH), the Logest-Path-Algorithm (LP) ad the Logest-Path-Algorithm followed by the Simple-Greedy-Algorithm (LP+ SG) for the examples described i the itroductio. We compare their bisectio widths with the optimal oes ad additioally compare their executio times. Fially we graphically preset oe typical example of all three graph classes. We color all areas at the oe side of the bisectio with red ad all areas at the other side of the bisectio with gree. Areas betwee the sides of the bisectio are ot colored. For the 6
Logest-Path-Algorithm, we additioally show, where are the startig vertices x ad y. I the tables let be the umber of vertices ad m the umber of edges of the graph. 4.1 Uiform refiemet SG KL RBH LP LP+SG OPT = 9 Bisectio width 5 5 7 6 5 5 m = 16 Executio time 00:00:00 00:00:00 00:00:00 00:00:00 00:00:00 = 25 Bisectio width 12 9 9 9 9 9 m = 56 Executio time 00:00:00 00:00:00 00:00:00 00:00:00 00:00:00 = 81 Bisectio width 55 37 31 20 18 17 m = 208 Executio time 00:00:00 00:00:02 00:00:01 00:00:00 00:00:00 = 289 Bisectio width 98 88 69 35 33 33 m = 800 Executio time 00:00:00 00:02:33 00:00:37 00:00:00 00:00:00 = 1089 Bisectio width 442 207 105 69 66 65 m = 3136 Executio time 00:00:05 05:44:04 00:33:46 00:00:02 00:00:06 = 4225 Bisectio width 1890 1501 261 131 129 129 m = 12416 Executio time 00:01:23 240:27:19 33:20:59 00:00:32 00:01:35 = 16641 Bisectio width 7750 265 258 257 m = 49408 Executio time 00:22:53 00:08:35 00:25:11 Table 1. Triagularizatio graphs with uiform refiemet 7
SG-Algorithm KL-Algorithm RBH-Algorithm y LP-Algorithm x LP+SG-Algorithm/ Optimal Solutio Fig. 1. Example for uiform refiemet: = 289, m = 800 From the structure of the graph, the optimal bisectio width of step k of refiemet ca easily be show to be 2 k+1 + 1. The Kerigha-Li-Algorithm ad the Radomized-Black-Holes-Algorithm produce better results tha the Simple-Greedy-Algorithm. Although they eed much more executio time, they give cosiderably worse results tha the two versios of the Logest-Path- Algorithm. The Simple-Greedy-Algorithm after the Logest-Path- Algorithm leads oly to a small improvemet. With the Logest- Path-Algorithm followed by the Simple-Greedy-Algorithm, we fid a optimal solutio or a solutio, oly larger by 1, i compariso to the optimal oe. 8
4.2 Refiemet at oe side For these graphs, the optimal bisectio width of step k of refiemet is 2k + 3. The Logest-Path-Algorithm followed by the Simple- Greedy-Algorithm fids a optimal solutio i all cases. The other results are similar to the case of uiform refiemet. SG KL RBH LP LP+SG OPT = 9 Bisectio width 5 5 7 6 5 5 m = 16 Executio time 00:00:00 00:00:00 00:00:00 00:00:00 00:00:00 = 18 Bisectio width 7 7 11 7 7 7 m = 39 Executio time 00:00:00 00:00:00 00:00:00 00:00:00 00:00:00 = 35 Bisectio width 18 11 9 9 9 9 m = 84 Executio time 00:00:00 00:00:00 00:00:00 00:00:00 00:00:00 = 68 Bisectio width 11 11 27 15 11 11 m = 173 Executio time 00:00:00 00:00:03 00:00:00 00:00:00 00:00:00 = 133 Bisectio width 33 31 39 17 13 13 m = 350 Executio time 00:00:00 00:00:21 00:00:03 00:00:00 00:00:00 = 262 Bisectio width 81 109 69 34 15 15 m = 703 Executio time 00:00:00 00:02:09 00:00:27 00:00:00 00:00:00 = 519 Bisectio width 173 149 49 50 17 17 m = 1408 Executio time 00:00:02 00:21:33 00:03:27 00:00:00 00:00:01 = 1032 Bisectio width 444 315 152 39 19 19 m = 2817 Executio time 00:00:05 02:50:37 00:27:15 00:00:02 00:00:05 = 2057 Bisectio width 546 87 43 21 21 m = 5634 Executio time 00:00:22 03:37:28 00:00:07 00:00:22 = 4106 Bisectio width 722 68 23 23 m = 11267 Executio time 00:01:37 00:00:29 00:01:27 = 8203 Bisectio width 2409 74 25 25 m = 22532 Executio time 00:06:17 00:01:58 00:05:56 = 16396 Bisectio width 5821 76 27 27 m = 45061 Executio time 00:21:49 00:07:54 00:23:08 Table 2. Triagularizatio graphs with refiemet at oe side 9
SG-Algorithm KL-Algorithm RBH-Algorithm y x LP-Algorithm LP+SG-Algorithm/ Optimal Solutio Fig. 2. Example for refiemet at oe side: = 133, m = 350 10
4.3 Refiemet at all sides SG KL RBH LP LP+SG OPT = 9 Bisectio width 5 5 7 6 5 5 m = 16 Executio time 00:00:00 00:00:00 00:00:00 00:00:00 00:00:00 = 25 Bisectio width 12 9 9 9 9 9 m = 56 Executio time 00:00:00 00:00:00 00:00:00 00:00:00 00:00:00 = 73 Bisectio width 21 21 31 16 16 15 m = 184 Executio time 00:00:00 00:00:02 00:00:01 00:00:00 00:00:00 = 185 Bisectio width 64 59 75 38 19 19 m = 488 Executio time 00:00:00 00:00:44 00:00:09 00:00:00 00:00:00 = 425 Bisectio width 134 103 73 64 25 25 m = 1144 Executio time 00:00:01 00:15:58 00:01:58 00:00:00 00:00:01 = 921 Bisectio width 238 275 105 118 32 32 m = 2504 Executio time 00:00:04 02:44:46 00:20:07 00:00:01 00:00:04 = 1929 Bisectio width 432 224 97 34 m = 5272 Executio time 00:00:22 00:00:07 00:00:20 = 3961 Bisectio width 902 418 44 43 m = 10856 Executio time 00:01:28 00:00:27 00:01:23 = 8041 Bisectio width 2720 808 47 45 m = 22072 Executio time 00:05:25 00:01:53 00:05:46 = 16217 Bisectio width 5026 1580 53 53 m = 44552 Executio time 00:22:24 00:07:45 00:23:29 Table 3. Triagularizatio graphs with refiemet at all sides 11
SG-Algorithm KL-Algorithm RBH-Algorithm y x LP-Algorithm LP+SG-Algorithm Optimal Solutio Fig. 3. Example for refiemet at all sides: = 425, m = 1144 As there is o trivial formula for the optimal bisectio width, we calculate it separately for every step of refiemet. The Simple-Greedy-Algorithm after the Logest-Path-Algorithm gives a much smaller bisectio width. Except for step k = 7 of refiemet, we fid a optimal or almost optimal solutio. The case k = 7 gives such a bad result, as there are two gree areas i the red area, ad so there is ot oly oe lie, separatig the two areas. For regular structures like rectagular grid graphs or the graph of uiform refiemet of sectio 4.1 this case caot appear. 5 Coclusios I most cases the Logest-Path-Algorithm followed by the Simple- Greedy-Algorithm fids bisectios with miimum bisectio width. 12
These bisectio widths are cosiderably smaller tha those that ca be obtaied from previous algorithms. The executio times as well as the complexity of the algorithm is better or equal to previous algorithms. Ackowledgemet I would like to thak Wolfgag Hackbusch ad Aad Srivastav for itroducig me to the partitioig problem of hierarchical matrices as well as for the idea of the Logest-Path-Algorithm ad Lars Grasedyck for some hits for implemetig ad graphically presetig the graphs. Refereces 1. R.B. Boppaa, Eigevalues ad Graph Bisectio: A Average-Case Aalysis, IEEE Symposium o Foudatios of Computer Sciece (FOCS) (1987), 280-285. 2. U. Feige, R. Krauthgamer ad K. Nissim, Approximatig the Miimum Bisectio Size, Aual ACM Symposium o Theory of Computig (STOC) (2000), 530-536. 3. A. Ferecz, R. Szewczyk, J. Weistei ad J. Wilkeig, Graph Bisectio, Fial Report, Uiversity of Califoria at Berkeley (1999). 4. L. Grasedyck, Theorie ud Aweduge Hierarchischer Matrize, Ph. D. Thesis, Uiversity of Kiel (2001). 5. W. Hackbusch, A Sparse Matrix Arithmetic Based o H-Matrices. Part I: Itroductio to H-Matrices, Computig, 62 (1999), 89-108. 6. W. Hackbusch ad B. Khoromskij, A Sparse H Arithmetic. Part II: Applicatio to Multi-Dimesioal Problems, Computig, 64 (2000), 21-47. 7. B.W. Kerigha ad S. Li, A Efficiet Heuristic Procedure for Partitioig Graphs, The Bell System Techical Joural, 49(2) (1970), 291-307. 8. C.H. Papadimitriou ad M. Sideri, The Bisectio Width of Grid Graphs, Mathematical Systems Theory, 29 (1996), 97-110. 9. H. Sara ad V.V. Vazirai, Fidig k Cuts withi Twice the Optimal, SIAM J. Comput., 24(1) (1995), 101-108. 13