A linear time algorithm for finding tree-decompositions of small treewidth ? Hans L. Bodlaendery Department of Computer Science , Utrecht University P.O. Box 80.089 , 3508 TB Utrecht , the Netherlands Abstract In this paper , we give , for constant k , a linear time algorithm , that given a graph G = -LRB- V ; E -RRB- , determines whether the treewidth of G is at most k , and if so , finds a tree-decomposition of G with treewidth at most k . A consequence is that every minor-closed class of graphs that does not contain all planar graphs has a linear time recognition algorithm . Another consequence is that a similar result holds when we look instead for path-decompositions with pathwidth at most some constant k. AMS-classification : 68R10 , 05C85 , 05C05 1 Introduction 1.1 Background The notions of ` tree-decomposition ' and ` treewidth ' have received much attention recently , not in the least due to the important role they play in the deep results on graph minors by Robertson and Seymour -LRB- see e.g. -LSB- 26 , 27 , 29 , 30 , 28 -RSB- , and many other papers in this series -RRB- . -LRB- See also -LSB- 20 -RSB- . -RRB- Also , many graph problems , including a very large number of well known NP-hard problems , have been shown to be linear time solvable on graphs that are given together with a tree-decomposition of treewidth at most k , for constant k. -LRB- See , amongst others -LSB- 2 , 5 , 6 , 7 , 11 , 9 , 13 , 14 , 15 , 31 , 33 -RSB- . -RRB- The first step of algorithms that exploit small treewidth of input graphs is to find a tree-decomposition with treewidth bounded by a constant , although possible ? This work was partially supported by the ESPRIT Basic Research Actions of the EC under contract 7141 -LRB- project ALCOM II -RRB- . yEmail : hansb@cs.ruu.nl not optimal . So far , this step dominated the running time of most algorithms , as the second step -LRB- some kind of ` dynamic programming ' algorithm using the treedecomposition -RRB- usually costs only linear time . The best algorithm known so far for this ` first step ' was an algorithm by Reed -LSB- 25 -RSB- , which costs O -LRB- n log n -RRB- . In this paper , we improve on this result , and give a linear time algorithm . The problem ` Given a graph G = -LRB- V ; E -RRB- and an integer k , is the treewidth of G at most k ' is NP-complete -LSB- 3 -RSB- . Much work has been done on this problem for constant k. For k = 1 ; 2 ; 3 , linear time algorithms exist -LSB- 24 -RSB- . Arnborg et al. -LSB- 3 -RSB- showed that the problem is solvable in O -LRB- nk +2 -RRB- time for constant k. Then , Robertson and Seymour gave a non-constructive proof of the existence of O -LRB- n2 -RRB- decision algorithms -LSB- 28 -RSB- . Actually , this algorithm is of a ` two steps ' form , as described above . The first step is to apply an O -LRB- n2 -RRB- algorithm , that either outputs that the treewidth of G is larger than k , or outputs a tree-decomposition with treewidth at most 4k . -LRB- Actually , the result is stated in -LSB- 28 -RSB- in terms of ` branchwidth ' , but this is an unimportant technical difference . -RRB- The second step checks in linear time a finite characterization of the graphs with treewidth at most k in terms of forbidden minors . In -LSB- 8 -RSB- -LRB- using results from -LSB- 19 -RSB- -RRB- it was shown that the non constructive elements can be avoided using self-reduction without increasing the running time by more than a -LRB- huge -RRB- constant factor . Both Lagergren -LSB- 22 -RSB- and Reed -LSB- 25 -RSB- improve on the ` first step ' . Lagergren gives a sequential algorithm that uses O -LRB- n log2 n -RRB- time , and a parallel algorithm that uses O -LRB- n -RRB- processors and O -LRB- log3n -RRB- time . Reed gives a sequential O -LRB- n log n -RRB- algorithm , which can be seen to have a parallel implementation with O -LRB- n = log n -RRB- processors and O -LRB- log2 n -RRB- time . A related probabilistic result -LRB- with running time O -LRB- n log2 n + nj log pj -RRB- , p the error of probability -RRB- was found by Matous > = ek and Thomas -LSB- 24 -RSB- . Each of these algorithms either determines that the input graph G has treewidth more than k , or finds a tree-decomposition of G with treewidth bounded by some constant -LRB- linear in k -RRB- . They all are based upon finding ` balanced separators ' in some clever ways . Our algorithm uses a different approach : we reduce the problem in linear time to a problem on a smaller graph by edge contraction or removing ` simplicial vertices ' . Independently , Lagergren and Arnborg -LSB- 23 -RSB- and Bodlaender and Kloks -LSB- 11 , 21 -RSB- showed that the ` second step ' can be done without use of graph minors , and give explicit algorithms to test in linear time whether G has treewidth at most k , once a tree-decomposition of G with bounded treewidth is available . Moreover , from these results it follows that a technique of Fellows and Langston -LSB- 18 -RSB- can be used to compute the obstruction set of the class of graphs with treewidth < = k. Bodlaender and Kloks also show how if existing , a tree-decomposition with treewidth at most k can be computed in the same time bounds . Results of a similar flavor were obtained independently by Abrahamson and Fellows -LSB- 1 -RSB- . Recognition algorithms for graphs with treewidth < = k -LRB- k constant -RRB- have been designed by Arnborg et al. -LSB- 4 -RSB- . These algorithms use linear time , but polynomial , not linear memory -LRB- it is allowed that the algorithm consults the contents of memory that is never written to -RRB- . A disadvantage of this approach is that it is not known how to construct tree-decompositions with small treewidth by the method . 1.2 Main idea of algorithm The main result in this paper is the following . Theorem 1.1 For all k 2 N , there exists a linear time algorithm , that tests whether a given graph G = -LRB- V ; E -RRB- has treewidth at most k , and if so , outputs a treedecomposition of G with treewidth at most k . The main idea of the algorithm is as follows : vertices are partitioned into two sets , one with vertices of ` low degree ' , and one with vertices of ` high degree ' . It can be shown for graphs with treewidth at most fixed constant k , that there are only ` few ' high degree vertices . Two cases are distinguished : 1 . ` Sufficiently many ' vertices of low degree are adjacent to one or more other vertices of low degree . In this case , it can be shown that any maximal matching in G contains sufficiently many -LRB- ? -LRB- n -RRB- -RRB- edges . We compute the graph G0 obtained by contracting all edges in a maximal matching . Recursively , we compute a tree-decomposition of treewidth at most k of G0 , or conclude that the treewidth of G0 , and hence the treewidth of G is larger than k. From this tree-decomposition , one easily can build a tree-decomposition of G with treewidth at most 2k + 1 . This latter tree-decomposition is used to solve the problem , using the algorithm of Bodlaender and Kloks -LSB- 11 , 21 -RSB- , mentioned above . 2 . ` Only few ' vertices of low degree are adjacent to one or more other vertices of low degree . It is shown that a certain collection of edges can be added to G without increasing the treewidth from a number at most k to a number larger than k . The ` improved graph of G ' -LRB- G with this collection of edges added -RRB- is shown to have sufficiently many -LRB- ? -LRB- n -RRB- -RRB- vertices which are I-simplicial : their neighbors form a clique in the improved graph -LRB- and they fulfill some other , less important conditions -RRB- . Recursively , a tree-decomposition with treewidth at most k is computed of G0 , obtained by removing all I-simplicial vertices from the improved graph of G , or one concludes that the treewidth of G0 , and hence of G is larger than k. Given such a tree-decomposition of G0 , one easily computes a tree-decomposition of G with treewidth at most k . In each case , the amount of work of the non-recursive steps is linear , and each G0 has size at most a constant fraction of the size of G . It follows that the algorithm uses linear time . 2 Definitions and preliminary results The notion of treewidth was introduced by Robertson and Seymour -LSB- 26 -RSB- . Definition . A tree-decomposition of a graph G = -LRB- V ; E -RRB- is a pair -LRB- fXi j i 2 Ig ; T = -LRB- I ; F -RRB- -RRB- with fXi j i 2 Ig a family of subsets of V , one for each node of T , and T a tree such that ffl Si2I Xi = V . ffl for all edges -LRB- v ; w -RRB- 2 E , there exists an i 2 I with v 2 Xi and w 2 Xi . ffl for all i ; j ; k 2 I : if j is on the path from i to k in T , then Xi \ Xk ? Xj . The treewidth of a tree-decomposition -LRB- fXi j i 2 Ig ; T = -LRB- I ; F -RRB- -RRB- is maxi2I jXij ? 1 . The treewidth of a graph G is the minimum treewidth over all possible treedecompositions of G . We use -LRB- X ; T -RRB- as a shorthand notation for -LRB- fXi j i 2 Ig ; T = -LRB- I ; F -RRB- -RRB- . There are several equivalent notions , e.g. a graph is a partial k-tree , if and only if its treewidth is at most k -LSB- 32 -RSB- . We give some well known or easily derivable results . Lemma 2.1 If the treewidth of G = -LRB- V ; E -RRB- is at most k , then jEj < = kjV j ? 12 k -LRB- k +1 -RRB- . Lemma 2.2 -LRB- See e.g. -LSB- 12 -RSB- . -RRB- Suppose -LRB- fXi j i 2 Ig ; T = -LRB- I ; F -RRB- -RRB- is a treedecomposition of G = -LRB- V ; E -RRB- . -LRB- i -RRB- If W ? V forms a clique in G , then 9i 2 I : W ? Xi . -LRB- ii -RRB- If W1 , W2 induce a complete bipartite subgraph in G , i.e. , each vertex in W1 is adjacent to each vertex in W2 , then 9i 2 I : W1 ? Xi or W2 ? Xi . Lemma 2.3 If -LRB- X ; T -RRB- is a tree-decomposition of G = -LRB- V ; E -RRB- , and 9i 2 I : v ; w 2 Xi , v < > w , then -LRB- X ; T -RRB- is also a tree-decomposition of G + -LRB- v ; w -RRB- = -LRB- V ; E -LSB- f -LRB- v ; w -RRB- g -RRB- . Lemma 2.4 Suppose v and w have at least k +1 common neighbors in G = -LRB- V ; E -RRB- . If the treewidth of G is at most k , then the treewidth of G + -LRB- v ; w -RRB- is also at most k. Moreover , any tree-decomposition of G with treewidth at most k is also a treedecomposition of G + -LRB- v ; w -RRB- with treewidth at most k and vice versa . Proof : Suppose -LRB- X ; T -RRB- is a tree-decomposition of G with treewidth at most k. By lemma 2.2 -LRB- b -RRB- either there exists an i 2 I with v ; w 2 Xi , in which case the lemma directly follows , or there exists an i 2 I with Xi contains the set W of all common neighbors of v and w. Now , if we add edges between all non-adjacent vertices in W , we obtain a graph G0 that contains a clique with size at least k + 2 -LRB- namely W -LSB- fvg -RRB- and has -LRB- X ; T -RRB- as a tree-decomposition . But a graph with treewidth < = k can not contain a clique with more than k + 1 vertices , contradiction . 2 A contraction is the operation that removes two adjacent vertices v , w , and replaces them by one new vertex that is made adjacent to all vertices that were adjacent to v and w . We say a tree-decomposition -LRB- X ; T -RRB- of treewidth k is smooth , if for all i 2 I : jXij = k + 1 , and for all -LRB- i ; j -RRB- 2 F : jXi \ Xjj = k. Any tree-decomposition of a graph G can be transformed to a smooth tree-decomposition of G with the same treewidth : apply the following operations until none is possible : ffl If for -LRB- i ; j -RRB- 2 F , Xi ? Xj , then contract the edge -LRB- i ; j -RRB- in T and take for the new node Xj0 = Xj . ffl If for -LRB- i ; j -RRB- 2 F , Xi 6 ? Xj and jXjj < k + 1 , then choose a vertex v 2 Xi ? Xj , and add v to Xj . ffl If for -LRB- i ; j -RRB- 2 F , jXij = jXjj = k + 1 , and jXi ? Xjj > 1 , then subdivide the edge -LRB- i ; j -RRB- in T ; let i0 be the new node ; choose a vertex v 2 Xi ? Xj and a vertex w 2 Xj ? Xi , and let Xi0 = Xi ? fvg -LSB- fwg . Lemma 2.5 If -LRB- X ; T -RRB- is a smooth tree-decomposition of G = -LRB- V ; E -RRB- with treewidth k , then jIj = jV j ? k. Proof : With induction to jIj . If jIj = 1 , then clearly jV j = k + 1 . Suppose the lemma holds for jIj = r ? 1 . Consider a smooth tree-decomposition -LRB- X ; T -RRB- of a graph G = -LRB- V ; E -RRB- with treewidth k , with jIj = r. Let i be a leaf of T . There is a unique vertex v that belongs to Xi , but not to any set Xj , j 2 I ? fig . If we remove node i from T , we get a smooth tree-decomposition of G -LSB- V ? fvg -RSB- with treewidth k and with jIj ? 1 nodes . The result now follows by induction . 2 In the remainder , we assume that k is a given fixed constant . We choose constants c1 , c2 2 R + , such that c2 = 1 4k2 + 12k + 16 ? c1 ? k2 -LRB- k + 1 -RRB- 2 > -LRB- Note that c1 and c2 are both constants between and 1 . c1 denotes an upper bound on the fraction of vertices that is of ` high degree ' -LRB- defined below -RRB- , and c2 denotes a lower bound on the fraction of vertices that is remove in one of the two cases of the main part of the algorithm . -RRB- Let d = max -LRB- k2 + 4k + 4 ; d2k = c1e -RRB- . We say a vertex with degree at most d is a low degree vertex , and a vertex with degree larger than d is a high degree vertex . A vertex is said to be friendly , if it is a low degree vertex and it is adjacent to at least one other low degree vertex . Lemma 2.6 There are less than c1 ? jV j high degree vertices in a graph with treewidth k. Proof : If there are nl high degree vertices , then G must contain at least nl ? d = 2 edges . By lemma 2.1 , nl ? d = 2 < kjV j. 2 A maximal matching of a graph G = -LRB- V ; E -RRB- is a set of edges M ? E such that no two edges in M share an endpoint , and every e 2 E ? M shares an endpoint with an edge in M . One easily finds a maximal matching in O -LRB- jV j + jEj -RRB- time with a greedy algorithm . Lemma 2.7 If there are nf friendly vertices in G = -LRB- V ; E -RRB- , then any maximal matching of G contains at least nf = -LRB- 2d -RRB- edges . Proof : Consider a maximal matching M . Any friendly vertex must be endpoint of an edge in M , or adjacent to a friendly vertex that is endpoint of an edge in M . To each edge e of M , we can associate the at most 2d friendly vertices that are endpoint of e or adjacent to a friendly -LRB- and hence low degree -RRB- endpoint of e . If a friendly vertex has not been associated to at least one edge in M , then M is not maximal . Hence jM j > = nf = -LRB- 2d -RRB- . 2 Let M be a maximal matching in G = -LRB- V ; E -RRB- , and let G0 = -LRB- V ; E -RRB- be the graph obtained by contracting all edges in M . Define fM : V ! V by fM -LRB- v -RRB- = v if v is not an endpoint of an edge in M , and let fM -LRB- v -RRB- = fM -LRB- w -RRB- be the vertex resulting of contracting edge -LRB- v ; w -RRB- 2 M . Lemma 2.8 Let M , G , G0 , fM be as above . If -LRB- X ; T -RRB- is a tree-decomposition of G0 with treewidth k , then -LRB- Y ; T -RRB- , defined by Yi = fv 2 V j fM -LRB- v -RRB- 2 Xig is a treedecomposition of G with treewidth at most 2k + 1 . Proof : This follows easily from the definitions . 2 Lemma 2.9 Let G , G0 be as above . The treewidth of G0 is at most the treewidth of G. Proof : G0 is a minor of G . The treewidth of a graph can not increase by taking minors . 2 The set of neighbors of a vertex v in G = -LRB- V ; E -RRB- is denoted by NG -LRB- v -RRB- = fw 2 V j -LRB- v ; w -RRB- 2 Eg . Finally , we mention some algorithmic results . Theorem 2.10 -LRB- Bodlaender , Kloks -LSB- 11 , 21 -RSB- -RRB- For all k , l , there exists a linear time algorithm , that when given a graph G = -LRB- V ; E -RRB- together with a tree-decomposition -LRB- X ; T -RRB- of G with treewidth at most l , determines whether the treewidth of G is at most k , and if so , finds a tree-decomposition of G with treewidth at most k . When we are given a graph G = -LRB- V ; E -RRB- as a collection of r edges where some edges of G may appear more than once in the collection , we can remove all multiple copies of edges in O -LRB- jV j + r -RRB- time , by applying bucket sort twice . 3 Simplicial vertices For a graph G = -LRB- V ; E -RRB- , let the improved graph G0 = -LRB- V ; E -RRB- of G be the graph , obtained by adding an edge -LRB- v ; w -RRB- to E for all pairs v , w 2 V such that v and w have at least k + 1 common neighbors of low degree in G. Lemma 3.1 If the treewidth of G is at most k , then the treewidth of the improved graph of G is at most k. Moreover , any tree-decomposition of G with treewidth at most k is also a tree-decomposition of the improved graph with treewidth at most k , and vice versa . Proof : This follows directly from lemma 2.4 . 2 We say a vertex v is simplicial in G , if its neighbors form a clique in G . We say v is I-simplicial , if it is simplicial in the improved graph of G , it is of low degree in G , and it is not a friendly vertex in G. -LRB- These latter two requirements are needed for obtaining a linear running time of the algorithm . -RRB- We now derive , by a series of lemmas the following result that states that if we have ` few ' high degree vertices and ` few ' friendly vertices , then if the treewidth of G is at most k , then we have ` many ' I-simplicial vertices . Theorem 3.2 For every graph G = -LRB- V ; E -RRB- , at least one of the following properties holds : ffl G contains at least jV j = -LRB- 4k2 + 12k + 16 -RRB- friendly vertices . ffl The improved graph of G contains at least I-simplicial vertices . ffl The treewidth of G is larger than k. Proof : The proof of theorem 3.2 will be given with help of several lemmas . A vertex v 2 V is said to be pretty with respect to some tree-decomposition -LRB- X ; T -RRB- , if it is of low degree , not friendly , and there exists a node i 2 I , such that all neighbors of v belong to Xi . Lemma 3.3 Suppose -LRB- X ; T -RRB- is a smooth tree-decomposition of G = -LRB- V ; E -RRB- with treewidth k. -LRB- i -RRB- To every leaf i of T , one can associate a low degree vertex v 2 Xi , that is friendly or pretty with respect to -LRB- X ; T -RRB- , and there does not exist a j 2 I , j < > i , with v 2 Xj . -LRB- ii -RRB- To every path i0 ; i1 ; : : : ; ik2 +3 k +3 in T with i1 ; : : : ; ik2 +3 k +2 nodes of degree 2 in T , one can associate at least one vertex v 2 Xi1 -LSB- ? ? ? -LSB- Xik2 +3 k +2 that is friendly or pretty with respect to -LRB- X ; T -RRB- , such that v does not belong to a set Xj with j 2 I a node , not on this path . Proof : -LRB- i -RRB- Let j be the neighbor of leaf i in T . Let v be the unique vertex in Xi ? Xj . v is only adjacent to vertices in Xi . Either all neighbors of v are of high degree , in which case v is pretty w.r.t. -LRB- X ; T -RRB- , or a neighbor of v is of low degree , in which case v is friendly . -LRB- ii -RRB- Note that jXi0 -LSB- ? ? ? -LSB- Xik2 +3 k +3 j = k2 + 4k + 4 < = d. Hence all vertices in Xi1 -LSB- ? ? ? -LSB- Xik2 +3 k +2 ? -LRB- Xi0 -LSB- Xik2 +3 k +3 -RRB- are of low degree . Suppose neither of them is friendly , i.e. they are only adjacent to high degree vertices in Xi0 -LSB- Xik2 +3 k +3 . Suppose Xi0 contains r high degree vertices , say w1 ; : : : ; wr . Clearly r < = jXi0j = k + 1 . Each of these , say ws , belongs to successive sets Xi0 ; Xi1 ; ? ? ? ; Xiws . Suppose w.l.o.g. iw1 < = iw2 < = ? ? ? < = iwr . If some low degree vertex v belongs to exactly one set Xij , 1 < = j < = k2 +3 k +2 , then it must be pretty w.r.t. -LRB- X ; T -RRB- . If some low degree vertex v belongs only to -LRB- a subset of -RRB- sets Xiwj +1 ; : : : ; Xiwj +1 , then all neighbors of v belong to Xiwj +1 , hence v is pretty w.r.t. -LRB- X ; T -RRB- . All vertices in Xi1 -LSB- ? ? ? -LSB- Xik2 +3 k +2 not of one of these two types must belong to at least one of the sets Xi0 ; Xiw1 ; : : : ; Xiwr ; Xik2 +3 k +3 . This are in total at most -LRB- k + 1 -RRB- -LRB- k + 3 -RRB- = k2 + 4k + 3 vertices . So , at least one vertex in Xi1 -LSB- ? ? ? -LSB- Xik2 +3 k +2 ? Xi0 ? Xik2 +3 k +3 must be pretty w.r.t. -LRB- X ; T -RRB- . 2 A leaf-path collection of a tree T is a collection of leaves in T , plus a collection of paths of length k2 + 3k + 4 in T , where all nodes on a path which are not an endpoint of a path have degree 2 in T and do not belong to any other path in the collection . The size of the collection is the total number of leaves plus the total number of paths in the collection . Lemma 3.4 Each tree with r nodes contains a leaf-path collection of size at least r = -LRB- 2k2 + 6k + 8 -RRB- . Proof : Let rb be the number of nodes of degree at least 3 , rl the number of leaves , and r2 the number of nodes of degree 2 . Clearly , rb < rl . All nodes of degree 2 belong to < rl + rb connected components of the forest , obtained by removing all leaves and all nodes with degree 3 or larger from the tree . Each such component contains at most k2 + 3k + 3 nodes , not part of a leaf-path collection of maximum size . So , there are less than -LRB- rb + rl -RRB- -LRB- k2 + 3k + 3 -RRB- nodes of degree 2 , not on a path in the collection . Hence , there are at least r2 ? -LRB- rb + rl -RRB- -LRB- k2 + 3k + 1 -RRB- k2 + 3k + 4 paths in a leaf-path collection of maximum size . It follows that the maximum size of a leaf-path collection is at least max -LRB- rl ; r2 ? -LRB- rb + rl -RRB- -LRB- k2 + 3k + 3 -RRB- k2 + 3k + 4 + rl -RRB- > = 1 2 ? r k2 + 3k + 4 : 2 Corollary 3.5 If -LRB- X ; T -RRB- is a smooth tree-decomposition of G = -LRB- V ; T -RRB- with treewidth k , then G contains at least jV j = -LRB- 2k2 +6 k +8 -RRB- ? 1 vertices that are friendly , or pretty with respect to -LRB- X ; T -RRB- . Proof : T contains jV j ? k nodes -LRB- lemma 2.5 -RRB- . Now apply lemma 3.3 and 3.4 . 2 A set Y ? V of high degree vertices is said to be semi-important with respect to tree-decomposition -LRB- X ; T -RRB- of G = -LRB- V ; E -RRB- , if there exists an i 2 I with Y ? Xi . A set Y is said to be important , if it is semi-important w.r.t. -LRB- X ; T -RRB- and not contained in any larger semi-important set w.r.t. -LRB- X ; T -RRB- . Lemma 3.6 Let -LRB- X ; T -RRB- be a tree-decomposition of G = -LRB- V ; E -RRB- with treewidth k . The number of different important sets w.r.t. -LRB- X ; T -RRB- is at most the number of high degree vertices in G. Proof : Let L be the set of high degree vertices in G. -LRB- fXi \ L j i 2 Ig ; T -RRB- is a tree-decomposition of G -LSB- L -RSB- . Each important set Y is a set Xi \ L which is not contained in another set Xi0 \ L. Repeatedly , contract edges -LRB- i ; i0 -RRB- in T with Xi \ L ? Xi0 \ L , with the new formed node containing all vertices in Xi . The resulting tree-decomposition of G -LSB- L -RSB- contains the same maximal sets Xi and will have at most jLj nodes . 2 A function f that maps each pretty -LRB- with respect to some tree-decomposition -LRB- X ; T -RRB- -RRB- vertex v to an important -LRB- with respect to -LRB- X ; T -RRB- -RRB- set Y with NG -LRB- v -RRB- ? Y , is called a pretty-to-important-function for -LRB- X ; T -RRB- . By definition , a pretty-toimportant-function always exists . Lemma 3.7 Let f be a pretty-to-important-function for a smooth treedecomposition -LRB- X ; T -RRB- of G = -LRB- V ; E -RRB- with treewidth k. Let Y be an important set w.r.t. -LRB- X ; T -RRB- . Then at most 12 k2 -LRB- k +1 -RRB- pretty vertices w.r.t -LRB- X ; T -RRB- -LRB- and G -RRB- in f ? 1 -LRB- Y -RRB- are not I-simplicial . Proof : Assign each non-I-simplicial pretty vertex v to a pair of neighbors of v , that are non-adjacent in the improved graph . To each pair of vertices , there can not be assigned more than k vertices , as otherwise they would have at least k +1 common low degree neighbors , and there would be an edge between them in the improved graph . It follows that the number of non-I-simplicial pretty vertices v with f -LRB- v -RRB- = Y is at most 12 jY j ? -LRB- jY j ? 1 -RRB- < = 12 k2 -LRB- k + 1 -RRB- . 2 Now we can prove theorem 3.2 . Suppose that G contains less than jV j = -LRB- 4k2 + 12k + 16 -RRB- friendly vertices and that the treewidth of G is at most k. By lemma 2.6 , there are at most c1 ? jV j high degree vertices in G , and hence , by lemma 3.6 , the number of important sets w.r.t. an arbitrary smooth tree-decomposition -LRB- X ; T -RRB- of G with treewidth < = k is at most c1 ? jV j. Using the fact that a pretty-to-important function always exists , and lemma 3.7 , it follows that at most 12 k2 -LRB- k +1 -RRB- ? -LRB- c1 ? jV j ? 1 -RRB- helpful vertices w.r.t. -LRB- X ; T -RRB- are not I-simplicial . Using corollary 3.5 , it follows that jV j = -LRB- 2k2 + 6k + 8 -RRB- ? 1 ? jV j = -LRB- 4k2 + 12k + 16 -RRB- ? 12 k2 -LRB- k + 1 -RRB- ? -LRB- c1 ? jV j ? 1 -RRB- > = c2 ? jV j vertices are I-simplicial . This ends the proof of theorem 3.2 2 Lemma 3.8 Let -LRB- X ; T -RRB- be a tree-decomposition of treewidth at most k of the graph G0 , obtained by removing all I-simplicial vertices -LRB- and adjacent edges -RRB- from the improved graph of graph G = -LRB- V ; E -RRB- . Then , for all I-simplicial vertices v , there exists an i 2 I with NG -LRB- v -RRB- ? Xi . Proof : Note that by definition , I-simplicial vertices are non-adjacent in G , and their neighborhood forms a clique in the improved graph of G . The result now follows directly from lemma 2.2 -LRB- i -RRB- . 2 4 Main algorithm We now give a recursive description of the main algorithm . Some details will be discussed in section 5 . Our algorithm , when given a graph G = -LRB- V ; E -RRB- , either ffl outputs that the treewidth of G is larger than k ffl or outputs a tree-decomposition of G with treewidth at most k. For ` very small graphs ' -LRB- i.e. with at most some constant number of vertices -RRB- any other finite algorithm is used to solve the problem . Otherwise , the following algorithm is used : First , check whether jEj < = k ? jV j ? 12 k -LRB- k + 1 -RRB- . If this is not the case , we know by lemma 2.1 that the treewidth of G is larger than k : stop . Now , count the number of friendly vertices . If there are at least jV j = -LRB- 4k2 +12 k + 16 -RRB- friendly vertices , do the following : ffl Find a maximal matching M ? E in G. ffl Compute the graph G0 = -LRB- V ; E -RRB- , obtained by contracting every edge in M . ffl Recursively , apply the algorithm to G0 . ffl If G0 has treewidth larger than k : stop . The treewidth of G is also larger than k. -LRB- See lemma 2.9 . -RRB- ffl Suppose the recursive call yielded a tree-decomposition -LRB- X ; T -RRB- of G0 with treewidth k. Construct a tree-decomposition -LRB- Y ; T -RRB- of G with treewidth at most 2k + 1 , as in lemma 2.8 . ffl Use the algorithm of theorem 2.10 and solve the problem . If there are less than jV j = -LRB- 4k2 + 12k + 16 -RRB- friendly vertices , do the following : ffl Compute the improved graph of G. -LRB- See section 5 . -RRB- ffl If there exists a I-simplicial vertex with degree at least k + 1 then stop : the improved graph of G contains a clique with k +2 vertices , hence the treewidth of G is more than k. ffl Put all I-simplicial vertices in some set SL . Compute the graph G0 , obtained by removing all I-simplicial vertices and adjacent edges from G. ffl If jSLj < c2jV j , then stop : the treewidth of G is larger than k. -LRB- See theorem 3.2 . -RRB- ffl -LRB- Now jSLj > = c2jV j. -RRB- Recursively apply the algorithm on G0 . ffl If the treewidth of G0 is larger than k , then stop : as G0 is a subgraph of G , also the treewidth of G is larger than k. ffl Suppose the recursive call yielded a tree-decomposition -LRB- X ; T -RRB- of G0 with treewidth k. For all v 2 SL , find an iv 2 V with NG -LRB- v -RRB- ? Xiv , and add a new node jv to T with Xjv = fvg -LSB- NG -LRB- v -RRB- , and make jv adjacent to iv in T . -LRB- Such a node iv exists by lemma 3.8 . -RRB- The result is a tree-decomposition of G with treewidth at most k. Correctness of the algorithm follows from results given in sections 2 and 3 . The running time of the algorithm can be estimated as follows . Either we recursively apply the algorithm on a graph with -LRB- 1 ? 1 = -LRB- 2d -LRB- 4k2 +12 k + 16 -RRB- -RRB- -RRB- ? jV j vertices -LRB- lemma 2.7 -RRB- or on a graph with -LRB- 1 ? c2 -RRB- jV j vertices . Write c3 = max -LRB- 1 ? c2 ; 1 ? 1 2d ? -LRB- 4k2 + 12k + 16 -RRB- -RRB- : Note that < = c3 < 1 . As all non recursive steps have a linear time implementation -LRB- see also section 5 -RRB- , we have that , if the algorithm takes T -LRB- n -RRB- time on a graph with n vertices in the worst case , then T -LRB- n -RRB- < = T -LRB- c3 ? n -RRB- + O -LRB- n -RRB- , hence T -LRB- n -RRB- = O -LRB- n -RRB- . It also follows that the algorithm uses linear memory . 5 Some details of the algorithm In this section we show that the steps of the algorithm given in section 4 can be implemented in linear time and linear memory . Most steps are rather straightforward , and left to the reader , or follow from earlier results . Note that we always may assume that the number of edges we are working with is linear in the number of vertices . We represent all graphs we work with by their adjacency lists . Computing the improved graph and the I-simplicial vertices Number the vertices v1 , v2 , : : : , vn . We use a queue Q , containing triples of the form -LRB- -LRB- v ; w -RRB- ; x -RRB- with v ; w ; x 2 V , or of the form -LRB- -LRB- v ; w -RRB- ;| -RRB- , v ; w 2 V . Also , we use an array S , with for each vi 2 V a stack S -LSB- vi -RSB- containing pairs of vertices . For all -LRB- vi ; vj -RRB- 2 E with i < j , put -LRB- -LRB- vi ; vj -RRB- ;| -RRB- on Q. For all low degree vertices v 2 V , for all pairs of neighbors vi ; vj 2 NG -LRB- v -RRB- with i < j , put -LRB- -LRB- vi ; vj -RRB- ; v -RRB- on Q . Now ` bucket sort ' Q twice , once to the first vertex entries , and once to the second vertex entries . After this double bucket sort , all pairs of the form -LRB- -LRB- vi ; vj -RRB- ; : : :-RRB- for fixed vj , vj will be in consecutive positions in Q. By inspecting Q , one can directly see what pairs of vertices have at least k + 1 low degree common neighbors . -LRB- If at least k + 1 entries -LRB- -LRB- vi ; vj -RRB- ; v -RRB- are adjacent in Q for some pair vi , vj , -LRB- vi ; vj -RRB- must be present in the improved graph . -RRB- For each such pair -LRB- vi ; vj -RRB- , and if a triple -LRB- -LRB- vi ; vj -RRB- ;| -RRB- is in Q , add the pair -LRB- vi ; vj -RRB- to all stacks S -LSB- v -RSB- for vertices v with -LRB- -LRB- vi ; vj -RRB- ; v -RRB- in Q . This all can be done in linear time , using the consecutiveness . Checking whether a low degree vertex v is I-simplicial can be done by inspecting S -LSB- v -RSB- : S -LSB- v -RSB- will consist precisely of all edges between neighbors of v . As v is of low degree , S -LSB- v -RSB- is of constant bounded size . Adding I-simplicial vertices back in the tree-decomposition Suppose we have a tree-decomposition -LRB- X ; T -RRB- of G -LSB- V ? SL -RSB- and we want to add all I-simplicial vertices in SL . For all l < = k , we take a queue Ql , in which we place all pairs -LRB- -LRB- vi1 ; : : : ; vil -RRB- ; i -RRB- for vi1 , : : : , vil 2 Xi , i 2 I , i1 < i2 < ? ? ? il , and all pairs -LRB- -LRB- vi1 ; : : : ; vil -RRB- ; v -RRB- with NG -LRB- v -RRB- = fvi1 ; : : : ; vil , i1 < i2 < ? ? ? < il . For each l , 1 < = l < = k , bucket sort Ql l times , once for each of the l positions in the l-tuple . All entries of the form -LRB- -LRB- vi1 ; : : : ; vil -RRB- ; : : :-RRB- will be at successive positions in Ql after this operation . By a simple scan of Ql , one can find for each entry -LRB- -LRB- vi1 ; : : : ; vil -RRB- ; v -RRB- an entry of the form -LRB- -LRB- vi1 ; : : : ; vil -RRB- ; i -RRB- for some i 2 I . This node i is precisely the node where the new node jv with Xjv = fvg -LSB- NG -LRB- v -RRB- can be made adjacent to . 6 Final remarks A consequence of the result of this paper is that all results that state that certain problems are solvable in linear time for graphs that are given together with a treedecomposition of constant bounded treewidth , are turned into results that state that these problems can be solved in linear time on graphs with constant bounded treewidth . One of the most notable of such results is the following . Theorem 6.1 Every class of graphs that is closed under taking of minors and does not contain all planar graphs has a linear time recognition algorithm . Proof : See e.g. -LSB- 28 -RSB- . Use the algorithm , described in this paper , to find a tree-decomposition with constant bounded treewidth of the input graph , and use this tree-decomposition to test for minor inclusion for all graphs in the obstruction set of the class . 2 In -LSB- 16 , 17 -RSB- several such classes of graphs can be found . For several of these notions , we expect that constructive linear time algorithms can be designed . Recent research -LSB- 10 -RSB- shows that linear time algorithms can be constructed that solve Minimum Cut Linear Arrangement , Search Number , and some related problems for constant k , and output for ` yes ' - instances the required linear arrangement . Note that the result shown in this paper is equivalent to stating that -LRB- for fixed k -RRB- partial k-trees can be recognized and embedded in a k-tree -LRB- or a chordal graph with maximum clique size k + 1 -RRB- in linear time . Also , a direct consequence is the following : Theorem 6.2 For all k 2 N , there exists a linear time algorithm , that tests whether a given graph G = -LRB- V ; E -RRB- has pathwidth at most k , and if so , outputs a pathdecomposition of G with pathwidth at most k. Proof : First , use the algorithm described in this paper . When the treewidth of G is larger than k , then clearly also the pathwidth of G is larger than k. Otherwise , use the result from -LSB- 11 , 21 -RSB- , that states for all constants k , l that gives a linear time algorithm , that given a tree-decomposition of treewidth at most l of G , tests whether G has pathwidth at most k and if so , finds a path-decomposition of G with pathwidth at most k. 2 The constant factor of the algorithm in this paper is very large , probably even for k = 4 it might be too large for practical purposes . Still , it is ` only ' exponential in a polynomial in k. Still , ideas and techniques in this paper may help to develop really practical algorithms for the ` treewidth < = k ' problem . As a small increase in the treewidth often gives a large increase in the constant factors , an advantage of our algorithm over others is that we never have to work with tree-decompositions with treewidth more than 2k + 1 . Also , finding I-simplicial vertices is done quite fast , and may be a good heuristic . Variants of our algorithm , perhaps with a better estimate of the constant c2 needed for the test jSLj < = c2 ? jV j may yield important savings in the constant factor of the running time . It is also possible to modify the algorithm , such that it uses the algorithm in -LSB- 11 , 21 -RSB- only on tree-decompositions with treewidth at most k + 1 , at the cost of increasing the running time to O -LRB- n log n -RRB- . Provided that the algorithm in -LSB- 11 , 21 -RSB- can be implemented quick enough , this modification may well be quite practical for small values of k -LRB- like k = 4 or k = 5 -RRB- . The idea is as follows : instead of using the construction of lemma 2.8 , first find a set M of at least jM j = -LRB- k + 1 -RRB- edges in M such that no two vertices which are the result of contracting an edge in M belong to a common set Xi . -LRB- Such a set can be quickly found in O -LRB- n -RRB- time : the graph H , obtained by adding an edge between every pair of vertices in G0 that share a common set Xi is a graph with treewidth k , hence is -LRB- k + 1 -RRB- - colorable . Hence , the set of vertices that are a result of an edge contraction contains an independent set in H of size at least jM j = -LRB- k + 1 -RRB- . Take M the set of edges corresponding to the vertices in this independent set . -RRB- Define fM as in section 2 . Now -LRB- Y ; T -RRB- , defined by Yi = fv 2 v j fM 2 Xig is a tree-decomposition of the graph , obtained from G by contracting all edges in M ? M with treewidth at most k + 1 . Use the algorithm from -LSB- 11 , 21 -RSB- to find a tree-decomposition of treewidth at most k of this graph . Repeat the process with this last tree-decomposition , and edge set M ? M until the edge set is empty . This are at most O -LRB- log n -RRB- iterations . -LRB- This observation was also made by Jens Lagergren . -RRB- It is possible to implement the algorithm , such that it runs on a pointer machine -LRB- a correct use of pointers is necessary , such that the addressing in the bucket sort algorithms can be done -RRB- , and still uses linear time . We omit the -LRB- easy -RRB- details . An interesting open problem is to find a parallel algorithm with a linear -LRB- or close to linear -RRB- time-processor product for the ` treewidth < = k ' problem . Acknowledgements I thank Jens Gustedt , Ton Kloks , Dieter Kratsch , and Bruce Reed for very useful comments on earlier draft versions of this paper . References -LSB- 1 -RSB- K. R. Abrahamson and M. R. Fellows . Finite automata , bounded treewidth and well-quasiordering . In Graph Structure Theory , Contemporary Mathematics vol . 147 , pages 539 -LCB- 564 . American Mathematical Society , 1993 . -LSB- 2 -RSB- S. Arnborg . Efficient algorithms for combinatorial problems on graphs with bounded decomposability -LCB- A survey . BIT , 25:2 -LCB- 23 , 1985 . -LSB- 3 -RSB- S. Arnborg , D. G. Corneil , and A. Proskurowski . Complexity of finding embeddings in a k-tree . SIAM J. Alg . Disc . Meth. , 8:277 -LCB- 284 , 1987 . -LSB- 4 -RSB- S. Arnborg , B. Courcelle , A. Proskurowski , and D. Seese . An algebraic theory of graph reduction . In H. Ehrig , H. Kreowski , and G. Rozenberg , editors , Proceedings of the Fourth Workshop on Graph Grammars and Their Applications to Computer Science , pages 70 -LCB- 83 . Springer Verlag , Lecture Notes in Computer Science , vol . 532 , 1991 . To appear in J. ACM . -LSB- 5 -RSB- S. Arnborg , J. Lagergren , and D. Seese . Easy problems for tree-decomposable graphs . J. Algorithms , 12:308 -LCB- 340 , 1991 . -LSB- 6 -RSB- S. Arnborg and A. Proskurowski . Linear time algorithms for NP-hard problems restricted to partial k-trees . Disc . Appl . Math. , 23:11 -LCB- 24 , 1989 . -LSB- 7 -RSB- H. L. Bodlaender . Dynamic programming algorithms on graphs with bounded tree-width . In Proceedings of the 15th International Colloquium on Automata , Languages and Programming , pages 105 -LCB- 119 . Springer Verlag , Lecture Notes in Computer Science , vol . 317 , 1988 . -LSB- 8 -RSB- H. L. Bodlaender . Improved self-reduction algorithms for graphs with bounded treewidth . In Proc . 15th Int . Workshop on Graph-theoretic Concepts in Computer Science WG ' 89 , pages 232 -LCB- 244 . Springer Verlag , Lect . Notes in Computer Science , vol . 411 , 1990 . To appear in : Annals of Discrete Mathematics . -LSB- 9 -RSB- H. L. Bodlaender . A tourist guide through treewidth . Technical Report RUU - CS-92-12 , Department of Computer Science , Utrecht University , Utrecht , 1992 . To appear in Acta Cybernetica . -LSB- 10 -RSB- H. L. Bodlaender , M. R. Fellows , and M. Halett , 1993 . Unpublished results . -LSB- 11 -RSB- H. L. Bodlaender and T. Kloks . Better algorithms for the pathwidth and treewidth of graphs . In Proceedings of the 18th International Colloquium on Automata , Languages and Programming , pages 544 -LCB- 555 . Springer Verlag , Lecture Notes in Computer Science , vol . 510 , 1991 . -LSB- 12 -RSB- H. L. Bodlaender and R. H. Mohring . The pathwidth and treewidth of cographs . SIAM J. Disc . Meth. , 6:181 -LCB- 188 , 1993 . -LSB- 13 -RSB- R. B. Borie , R. G. Parker , and C. A. Tovey . Automatic generation of lineartime algorithms from predicate calculus descriptions of problems on recursively constructed graph families . Algorithmica , 7:555 -LCB- 582 , 1992 . -LSB- 14 -RSB- B. Courcelle . The monadic second-order logic of graphs I : Recognizable sets of finite graphs . Information and Computation , 85:12 -LCB- 75 , 1990 . -LSB- 15 -RSB- B. Courcelle and M. Mosbah . Monadic second-order evaluations on treedecomposable graphs . Theor . Comp . Sc. , 109:49 -LCB- 82 , 1993 . -LSB- 16 -RSB- M. R. Fellows and M. A. Langston . Nonconstructive advances in polynomialtime complexity . Inform . Proc . Letters , 26:157 -LCB- 162 , 1987 . -LSB- 17 -RSB- M. R. Fellows and M. A. Langston . Nonconstructive tools for proving polynomial-time decidability . J. ACM , 35:727 -LCB- 739 , 1988 . -LSB- 18 -RSB- M. R. Fellows and M. A. Langston . An analogue of the Myhill-Nerode theorem and its use in computing finite-basis characterizations . In Proceedings of the 30th Annual Symposium on Foundations of Computer Science , pages 520 -LCB- 525 , 1989 . -LSB- 19 -RSB- M. R. Fellows and M. A. Langston . On search , decision and the efficiency of polynomial-time algorithms . In Proceedings of the 21rd Annual Symposium on Theory of Computing , pages 501 -LCB- 512 , 1989 . -LSB- 20 -RSB- D. S. Johnson . The NP-completeness column : An ongoing guide . J. Algorithms , 8:285 -LCB- 303 , 1987 . -LSB- 21 -RSB- T. Kloks . Treewidth . PhD thesis , Utrecht University , Utrecht , the Netherlands , 1993 . -LSB- 22 -RSB- J. Lagergren . Efficient parallel algorithms for tree-decomposition and related problems . In Proceedings of the 31rd Annual Symposium on Foundations of Computer Science , pages 173 -LCB- 182 , 1990 . -LSB- 23 -RSB- J. Lagergren and S. Arnborg . Finding minimal forbidden minors using a finite congruence . In Proceedings of the 18th International Colloquium on Automata , Languages and Programming , pages 533 -LCB- 543 . Springer Verlag , Lecture Notes in Computer Science , vol . 510 , 1991 . -LSB- 24 -RSB- J. Matous > = ek and R. Thomas . Algorithms finding tree-decompositions of graphs . J. Algorithms , 12:1 -LCB- 22 , 1991 . -LSB- 25 -RSB- B. Reed . Finding approximate separators and computing tree-width quickly . In Proceedings of the 24th Annual Symposium on Theory of Computing , pages 221 -LCB- 228 , 1992 . -LSB- 26 -RSB- N. Robertson and P. D. Seymour . Graph minors . II . Algorithmic aspects of tree-width . J. Algorithms , 7:309 -LCB- 322 , 1986 . -LSB- 27 -RSB- N. Robertson and P. D. Seymour . Graph minors . V. Excluding a planar graph . J. Comb . Theory Series B , 41:92 -LCB- 114 , 1986 . -LSB- 28 -RSB- N. Robertson and P. D. Seymour . Graph minors . XIII . The disjoint paths problem . Manuscript , 1986 . -LSB- 29 -RSB- N. Robertson and P. D. Seymour . Graph minors . IV . Tree-width and wellquasi-ordering . J. Comb . Theory Series B , 48:227 -LCB- 254 , 1990 . -LSB- 30 -RSB- N. Robertson and P. D. Seymour . Graph minors . X. Obstructions to treedecomposition . J. Comb . Theory Series B , 52:153 -LCB- 190 , 1991 . -LSB- 31 -RSB- P. Scheffler . Die Baumweite von Graphen als ein Mass fur die Kompliziertheit algorithmischer Probleme . PhD thesis , Akademie der Wissenschaften der DDR , Berlin , 1989 . -LSB- 32 -RSB- J. van Leeuwen . Graph algorithms . In Handbook of Theoretical Computer Science , A : Algorithms and Complexity Theory , pages 527 -LCB- 631 , Amsterdam , 1990 . North Holland Publ . Comp . -LSB- 33 -RSB- T. V. Wimer . Linear Algorithms on k-Terminal Graphs . PhD thesis , Dept. of Computer Science , Clemson University , 1987 .

O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O B O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O B O O O O O O B O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O B O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O B O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O B O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O B O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O B O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O B O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O B I O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O

graph algorithms
graph minors
pathwidth
treewidth


Tree-based Algorithm to Find the k-th Value in Distributed Systems Yoonsik Cheon and Johnny Wong TR # 94-07 April , 1994 1992 CR Categories : C. 2.4 -LSB- Computer-Communication Networks -RSB- Distributed Systems | Distributed applications ; To be presented in the Proceedings of the ISMM | International Conference on Intelligent Information Management Systems , Washinton , DC , June 1 -LCB- 3 , 1994 . Department of Computer Science 226 Atanasoff Hall Iowa Sate University Ames , Iowa 50011-1040 , USA Tree-based Algorithm to Find the k-th Value in Distributed Systems Yoonsik Cheon and Johnny Wong Department of Computer Science , 226 Atanasoff Hall Iowa State University , Ames , Iowa 50011-1040 USA cheon@cs.iastate.edu and wong@cs.iastate.edu Abstract In this paper , we study distributed algorithms for finding the k-th value in the decentralized systems . First we consider the case of circular configuration of processors where no processor knows the total number of participants . Later a network of arbitrary configuration is examined and a tree-based algorithm is proposed . The proposed algorithm requires O -LRB- N -RRB- messages and O -LRB- logN -RRB- rounds of message passing , where N is the number of nodes in the network . Keywords : searching k-th value , extrema finding , distributed algorithms , message passing , tree . 1 Introduction Given N processors or computer systems that communicate only with message passing , the distributed extrema-finding problem is to select the processor with the maximum -LRB- or minimum -RRB- value . Each processor is assumed to has a unique value in a set with a total order . The extrema-finding problem has been studied for quite some time now and several algorithms have appeared in the literature . We extend this problem to find the processor with the k-th largest -LRB- or smallest -RRB- value . Distributed extrema-finding in circular configuration of processors and where no processor knows the total number of participants has been extensively studied . The original solution is due to LeLann -LSB- 1 -RSB- who presented an algorithm that requires O -LRB- N2 -RRB- messages . Chang and Roberts -LSB- 2 -RSB- proposed an improved algorithm that requires only O -LRB- N log N -RRB- messages on the average but , in the worst case , still requires O -LRB- N2 -RRB- messages . Both algorithms assumed the capability of each processor to pass a message \ to the left '' in a global sense , i.e. , the communication is unidirec - tional . This condition was relaxed in -LSB- 3 -RSB- in that a processor can pass messages in either or both directions -LRB- i.e. , bidirectional communication -RRB- , giving an algorithm requiring O -LRB- N log N -RRB- messages in the worst case . Later , Peterson -LSB- 4 -RSB- showed that one still can achieve an O -LRB- N log N -RRB- algorithm with unidirectional communications , which is a unidirectional simulation of an bidirectional algorithm . The original problem was slightly modified in -LSB- 5 -RSB- in that they assumed knowledge of the number of participating processes and of the communication scheme , did not use circular configuration , and required the computation to be done within two rounds of message exchange . Using finite projective planes , they developed an algorithm of O -LRB- NpN -RRB- message passing . We propose two algorithms for finding the k-th value for a computer network of N nodes , communicating only by messages . The messages are guaranteed to be delivered by the communication network . Initially we assume that all the nodes are completely reliable , and node failures will be considered in the later section . The first algorithm is an extension to Peterson 's extrema-finding algorithm -LSB- 4 -RSB- . It requires O -LRB- logN -RRB- steps and each step requires O -LRB- N -RRB- message passing , thus requiring O -LRB- N log N -RRB- messages in total . In the second algorithm we do not require the processors to be configured in a circle . They can be in an arbitrary network topology . The algorithm uses a spanning tree of the computer network , and is based on the Raymond 's tree algorithm for distributed mutual exclusion problem -LSB- 6 -RSB- . The performance of the algorithm depends on the topology of the network spanning tree used , but the average number of steps -LRB- round of message passing -RRB- is O -LRB- logN -RRB- and the total number of messages is O -LRB- N -RRB- . The main contributions of our work is : -LRB- 1 -RRB- This seems to be the first work focused on finding the k - tid : = <my value> ; while -LRB- true -RRB- / * active stage * / send -LRB- tid -RRB- ; receive -LRB- ntid -RRB- ; if -LRB- my value 2 ntid -RRB- then announce found ; endif tid : = merge k -LRB- tid , ntid -RRB- ; send -LRB- tid -RRB- ; receive -LRB- nntid -RRB- ; if -LRB- my value in nntid -RRB- then announce found ; endif tid : = merge k -LRB- tid , nntid -RRB- ; if -LRB- :9 n -LRB- n 2 ntid ^ n 2 tid -RRB- -RRB- then break ; endif endwhile while -LRB- true -RRB- / * relay stage * / receive -LRB- ntid -RRB- ; if -LRB- my value 2 ntid -RRB- then announce found ; endif send -LRB- ntid -RRB- ; endwhile Figure 1 : An extension to Peterson 's extrama-finding algorithm th values in the distributed system . -LRB- 2 -RRB- It is shown that an existing extrema-finding algorithm can be easily extended to finding the k-th value . Though we showed only an extension to the Peterson 's algorithm , we expect other extrema-finding algorithms can also be generalized in the similar manner . -LRB- 3 -RRB- It is demonstrated that our tree-based algorithm can be easily and practically implemented using either BSD sockets or RPC . 2 An Extension to Peterson 's Algorithm Given N processors in a ring communicating only with message passing to its neighbors , the problem is to find the processor with the k-th largest -LRB- or smallest -RRB- value . All processors are identical except for their values . However , a processor can determine whether a message is received from its left neighbor or from its right neighbor . The number of processors , N , is not initially known , a property known as uniformity of the algorithms . The algorithm is shown in Figure 1 . It is an extension to the Peterson 's extrema finding algorithm -LSB- 4 -RSB- . All messages are assumed to be passed only to the right . Processors are divided into two categories : active and relay . Active processors operate in phases . Relay processors just pass on any messages they receive . All processors are initially active . Each processor starts with its own value as its temporary identifier -LRB- tid -RRB- . During a phase , each ac - tive process receives the values from its nearest active neighbor to the left -LRB- ntid -RRB- and that neighbors nearest left active neighbor -LRB- nntid -RRB- . Each message consists of a sequence of k values , i.e. , the variables tid , ntid , and nntid store sequences of values . When an active processor receives two messages tid and nntid , it computes -LRB- by merging -RRB- the largest k values among its own list of values and the 2k values just received , and forwards the newly computed k values to its right neighbor . If any value of ntid is included in the newly computed k largest values , the processor stays in the active stage ; otherwise it jumps to the relay step . Thus , at each phase , out of n processors about n = k of active processors move to the relay stage . The algorithm requires k ? 1 initialization steps -LRB- the first k ? 1 phases -RRB- during which no active processor jumps to the relay stage . These steps require -LRB- k ? 1 -RRB- N messages passes . Thus , in the worst case -LRB- i.e. , when k is equal to N -RRB- the algorithm requires O -LRB- N2 -RRB- message passes . However , when k is small enough compared to N , the average case complexity is O -LRB- N log N -RRB- . Since at each phase , n = k of active processors move to the relay stage , there can be at most blog Nc phases to reach one active processor . During each phase every processor sends -LRB- and receives -RRB- two messages , and at the last phase one active processor sends one message which is relayed around the ring , thus , giving total 2NblogNc + N messages . Therefore , the message complexity is O -LRB- N log N -RRB- . If k = 1 , the algorithm become the Peterson 's original algorithm . 3 Tree-Based Algorithm In this section we consider a network of arbitrary topology . The proposed algorithm is based on the Raymond 's tree-based distributed mutual exclusion algorithm -LSB- 6 -RSB- . The nodes are assumed to be arranged in an unrooted tree structure . The tree may be either a minimal spanning tree of the actual network topology , or merely a logical structure imposed on the underlying physical network . All messages travel along the -LRB- undirected -RRB- edges of this tree . There is no need for each node to be aware of the tree as a whole . It is sufficient for each node to know of the existence of its neighbors in the tree . When a node initiates a search of the k-th largest value -LRB- we call this node the initiating node -RRB- , it sends a request message to all its neighbors , which temporarily become the children of the requesting node . As the request message propagates through the tree , the tree becomes directed , 2 1 4 6 5 3A B F EDC Figure 2 : Tree with parent-directed edges -LRB- The node A initiated the search -RRB- . rooted by the initiating node . To capture this information , each node has a variable parent , which indicates the location of the initiating node relative to the node itself . Either a node is the initiating node or else it is located in a particular subtree of the node . Suppose that the node A initiates a search for the second largest value -LRB- see Figure 2 -RRB- . In the Figure a node 's value is shown beside it 's label . The node A sends a request message to its immediate neighbors : nodes B , C , and D . When the nodes B , C , and D receive this request message , they set their parent variables to A , and the node D propagates the request message to the nodes E and F. Both the nodes E and F set their parent variables to D . The tree temporarily become directed , rooted by the initiating node A , as shown in the figure . On receiving the request message for the second largest value from the node B , both the nodes E and F send their values -LRB- 1 and 6 respectively -RRB- to the node B . When the node B receives the values 1 and 6 from its children , it merges them with its own value -LRB- 4 -RRB- to select the two largest values -LRB- i.e. , 6 and 4 -RRB- and forward them to the node A , its current parent node . Similarly both the node C and D send their values -LRB- 2 and 5 respectively -RRB- to the node A . When the node A receives all the replies from its children , it merges them to find the second largest value -LRB- 5 -RRB- of the whole tree . If necessary , the node A can broadcast the found value to all the other nodes in the network . 3.1 Algorithm For simplicity , we assume that at one time only one node initiates the search . It is a simple exercise to extend the following algorithm to allow multiple searches by several initiating nodes concurrently . Assume that we want to find the k-th largest value , where k is less than or equal to the number of nodes in the tree . the node initiating the search becomes a temporary root of the tree . Each node computes parent : = sender ; / * sender can be the node itself * / n : = 0 ; if -LRB- num neighbor = 1 -RRB- / * leaf ? * / then send the message reply -LRB- my val -RRB- to parent parent : = nil ; else val -LSB- 1 -RSB- = my val ; n : = 1 ; for each child send the message find -LRB- k -RRB- to it ; endfor endif Figure 3 : Processing of the message find -LRB- k -RRB- . val -LSB- 1 . . min -LRB- k , n + m -RRB- -RSB- : = merge -LRB- val -LSB- 1 . . n -RSB- , n1 ; : : : ; nm -RRB- ; n = min -LRB- k , n + m -RRB- if -LRB- num of received messages = num of children -RRB- then if -LRB- parent = myself -RRB- then found the k-th largest value , val -LSB- k -RSB- ; else send reply -LRB- val -LSB- 1 -RSB- , : : : , val -LSB- n -RSB- -RRB- to parent ; parent : = nil ; endif endif Figure 4 : Processing of the message reply -LRB- n1 ; : : : , nm -RRB- the k largest values in the subtree rooted by itself and passes them to its temporary parent . The the initiating node , after receiving all the replies from its children , can compute the k-th largest value of the whole tree . An identical algorithm runs on each node of the tree . The search is initiated when some node sends a request message to itself , which becomes the temporary root . Two kinds of messages are used : find -LRB- k -RRB- message and reply -LRB- n1 ; n2 ; : : : ; nm -RRB- message . The find message is a request for search and is sent by the parent to its children , and the reply message is sent the other way around . Thus , we need to consider two cases : -LRB- 1 -RRB- when a node receives a find message and -LRB- 2 -RRB- when it receives a reply message . When a node receives a find -LRB- k -RRB- message from itself or one of its immediate neighbors , the algorithm in Figure 3 is executed . If the node is a leaf , then it simply sends its value to the sender ; otherwise , it forwards the request message to its children . When a node receives a reply -LRB- n1 ; : : : ; nm -RRB- -LRB- m < = k -RRB- message from itself or one of its children , the algo - rithm in Figure 4 is executed . The node merges the received values and the current values of val -LSB- 1 . . n -RSB- and stores them back to val . If the number of messages received so far is equal to the number of children -LRB- i.e. , received all replies from its children -RRB- , the node checks whether it is the initiating node . If it is , then the kth largest value is found in val -LSB- k -RSB- ; otherwise , it sends the new val -LSB- 1 . . n -RSB- to parent . The new val -LSB- 1 . . n -RSB- is the largest n values in the subtree rooted by the node . When the k-th value is found , if necessary , the initiating node can broadcast it to all other nodes in the network . 3.2 Complexity It is clear that only two messages are passed through each edge of the tree . One is the find message and the other is the reply message . Thus , the total number of messages required is twice the number of edges in the tree , i.e. , 2 -LRB- N ? 1 -RRB- , leading to the complexity of O -LRB- N -RRB- . This is the lower bound in the sense that for each node at least two messages are required : one for requesting , the other for replying . Therefore , our algorithm is optimal when considering the total number of messages required . How many steps -LRB- rounds of message passing -RRB- does our algorithm require ? It depends on the structure of the tree . If the height of the tree is h , then it needs h ? 1 steps to reach the out-most nodes . Thus , on the average the algorithm requires O -LRB- log N -RRB- steps . The best topology for our algorithm is a radiating star formation and the worst topology is a straight line arrangement . In any case , if the tree structure is logically imposed upon the underlying network , then pathological cases -LRB- e.g. , the straight line formation -RRB- can be avoided in favor of trees which approximates a radiating star formation . 4 Discussion we considered the problem of finding k-th value in the distributed systems . We first extended an existing extrema-finding algorithm -LSB- 4 -RSB- to finding the k-th value in a circular configuration . Later , a tree-based algorithm that requires O -LRB- log N -RRB- rounds and O -LRB- N -RRB- messages was devised . The tree-based algorithm has a couple of interesting features . First , when k is equal to N , they become distributed -LRB- merge -RRB- sorting algorithms . This is because we have to find k largest values to find the k-th value . The extended Peterson algorithm also has this property . Second , the algorithm does not require the uniqueness of node values ; even if several processors have the same value , the algorithm still works . In addition to the above features , the tree-based algorithm has a nice property that even if some node fails the algorithm still works . The parent of the failed node can detect by time-out that a node -LRB- or communication link -RRB- failure occurs . Once detected , the parent can either ignore the failed node or wait for its recovery . If it is ignored , the final value would be the k-th value of a partial tree , i.e. , the tree excluding the subtree rooted by the failure node . Multiple node failures can be treated in the same way . In the case of recovering , it is possible for the failed node to reconstruct the lost information from node 's neighbors when the node restarts . The recovering node needs to interact with only its immediate neighbors . The procedure will similar to that of Raymond 's -LSB- 6 -RSB- . The tree-based algorithm was implemented using both the Berkeley Software Distribution -LRB- BSD -RRB- Socket Programming Interface and Remote Procedure Call -LRB- RPC -RRB- . References -LSB- 1 -RSB- LeLann , G. Distributed systems | towards a formal approach . Information Processing Letter , 77:155 -LCB- 160 , 1977 . -LSB- 2 -RSB- Chang , E. and Robert , R . An improved algorithm for decentralized extrema-finding in circular configurations of processes . Communications of the ACM , 11 -LRB- 5 -RRB- :281 -LCB- 283 , May 1979 . -LSB- 3 -RSB- Hirschberg , D. and Sinclair , J. Decentralized extrema-finding in circular configurations of processors . Communications of the ACM , 23 -LRB- 11 -RRB- :627 -LCB- 628 , November 1980 . -LSB- 4 -RSB- Peterson , G. L . An O -LRB- n log n -RRB- unidirectional algorithm for the circular extrema problem . ACM Transactions on Programming Languages and Systems , 4 -LRB- 4 -RRB- :758 -LCB- 762 , October 1982 . -LSB- 5 -RSB- Lakshman , T. and Agrawala , A. K. Efficient decentralized consensus protocols . IEEE Transactions on Software Engineering , SE-12 -LRB- 5 -RRB- :600 -LCB- 607 , May 1986 . -LSB- 6 -RSB- Raymond , K . A tree-based algorithm for distributed mutual exclusion . ACM Transactions on Computer Systems , 7 -LRB- 1 -RRB- :61 -LCB- 77 , January 1989 .

O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O B I O B I O B I O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O

distributed algorithms
extrema finding
message passing