6
On the vertex separation of unicyclic graphs Hsin-Hung Chou * Department of Information Management, Chang Jung Christian University, Taiwan Ming-Tat Ko Institute of Information Science, Academia Sinica, Taiwan Chin-Wen Ho Department of Computer Science and Information Engineering, National Central University, Taiwan Gen-Huey Chen Department of Computer Science and Information Engineering, National Taiwan University, Taipei, Taiwan Abstract In the article “Computing the vertex separation of unicyclic graphs”, Information and Computa- tion 192, pp. 123–161, 2004, Ellis et al. pro- posed an O(n log n) algorithm for computing both the vertex separation and an optimal layout of a unicyclic graph with n vertices. Using the data structures label and label array, we improve the time complexity of their algorithm to O(n). 1 Background The vertex separation problem can be defined using linear layouts, see [1]. A linear layout of a graph G =(V,E) is a bijection L from V to the set of integers {1, 2,..., |V |}. The vertex separator at vertex v i with respective to a layout L, denoted by V L (i), is the set of vertices with indices less than or equal to i and with one neighbor having index greater than i, i.e., V L (i)= {v| (v,w)E, L(v) i, and L(w) >i}. The vertex separation with respect to G and L, denoted by vs L (G), is de- fined as the maximum vertex separator size over all vertex in V , i.e., vs L (G) = max{|V L (i)||1 i ≤|V |}. The vertex separation of G, denoted by vs(G), is defined as the minimum vertex sepa- ration over all possible linear layout L of G, i.e., vs(G) = min{vs L (G)|L is a linear layout of G}.A linear layout L of G is optimal if vs L (G)= vs(G). Recently the vertex separation problem has re- ceived more attention because it is equivalent to * Corresponding author. Email: [email protected] several well known important problems such as the node-searching problem [2], the gate matrix layout problem [3], and the path-width problem [4], with applications in VLSI layout. For some special classes of graphs, the above problems can be solved in polynomial time, such as unicyclic graphs [5], permutation graphs [6], k- starlike graphs [7], and partial k-trees [8] for a fixed k 1. Especially, trees [9] and cographs [10] can be solved in linear time. A unicyclic graph is a graph constructed from a tree with one extra edge [5]. It can be depicted as a cycle with a set of trees in which each cy- cle vertex is the root of a tree, referred to as a constituent tree. In [5], Ellis et al. proposed an O(n log n)-time algorithm for computing both the vertex separation and an optimal layout of a uni- cyclic graph with n vertices. Their algorithm com- prises two phases. In Phase 1, for a unicyclic graph U , the vertex separation, an optimal layout, and the type (de- fined in [5]) of each constituent tree are computed by the methods proposed in [1] and [9]. The meth- ods also used to compute the vertex separation k and an optimal layout L of T = U - e, which is the tree yielded by removing some cycle edge e from U . Phase 1 takes O(n) time. At its completion, we know k vs(U ) k + 1. In Phase 2, the goal is to determine whether vs(U ) = k, or vs(U ) = k + 1. The process is comprised of two functions vs uni and vs reduced uni, see Appendix. The function vs uni takes the unicyclic graph U and the inte- ger k = vs(T ) as input. It classifies the unicyclic graph as one of the five cases according to the

Vertex Separation of Unicyclic Graph

Embed Size (px)

DESCRIPTION

Research article

Citation preview

Page 1: Vertex Separation of Unicyclic Graph

On the vertex separation of unicyclic graphs

Hsin-Hung Chou∗

Department of Information Management, Chang Jung Christian University, TaiwanMing-Tat Ko

Institute of Information Science, Academia Sinica, TaiwanChin-Wen Ho

Department of Computer Science and Information Engineering,National Central University, Taiwan

Gen-Huey ChenDepartment of Computer Science and Information Engineering,

National Taiwan University, Taipei, Taiwan

Abstract

In the article “Computing the vertex separationof unicyclic graphs”, Information and Computa-tion 192, pp. 123–161, 2004, Ellis et al. pro-posed an O(n log n) algorithm for computing boththe vertex separation and an optimal layout of aunicyclic graph with n vertices. Using the datastructures label and label array, we improve thetime complexity of their algorithm to O(n).

1 Background

The vertex separation problem can be definedusing linear layouts, see [1]. A linear layout of agraph G = (V,E) is a bijection L from V to the setof integers {1, 2, . . . , |V |}. The vertex separator atvertex vi with respective to a layout L, denotedby VL(i), is the set of vertices with indices lessthan or equal to i and with one neighbor havingindex greater than i, i.e., VL(i) = {v| (v, w)∈ E,L(v) ≤ i, and L(w) > i}. The vertex separationwith respect to G and L, denoted by vsL(G), is de-fined as the maximum vertex separator size overall vertex in V , i.e., vsL(G) = max{|VL(i)||1 ≤i ≤ |V |}. The vertex separation of G, denotedby vs(G), is defined as the minimum vertex sepa-ration over all possible linear layout L of G, i.e.,vs(G) = min{vsL(G)|L is a linear layout of G}. Alinear layout L of G is optimal if vsL(G) = vs(G).

Recently the vertex separation problem has re-ceived more attention because it is equivalent to

∗Corresponding author. Email:[email protected]

several well known important problems such as thenode-searching problem [2], the gate matrix layoutproblem [3], and the path-width problem [4], withapplications in VLSI layout.

For some special classes of graphs, the aboveproblems can be solved in polynomial time, suchas unicyclic graphs [5], permutation graphs [6], k-starlike graphs [7], and partial k-trees [8] for afixed k ≥ 1. Especially, trees [9] and cographs[10] can be solved in linear time.

A unicyclic graph is a graph constructed froma tree with one extra edge [5]. It can be depictedas a cycle with a set of trees in which each cy-cle vertex is the root of a tree, referred to as aconstituent tree. In [5], Ellis et al. proposed anO(n log n)-time algorithm for computing both thevertex separation and an optimal layout of a uni-cyclic graph with n vertices. Their algorithm com-prises two phases.

In Phase 1, for a unicyclic graph U , the vertexseparation, an optimal layout, and the type (de-fined in [5]) of each constituent tree are computedby the methods proposed in [1] and [9]. The meth-ods also used to compute the vertex separation kand an optimal layout L of T = U−e, which is thetree yielded by removing some cycle edge e fromU . Phase 1 takes O(n) time. At its completion,we know k ≤ vs(U) ≤ k + 1.

In Phase 2, the goal is to determine whethervs(U) = k, or vs(U) = k + 1. Theprocess is comprised of two functions vs uni andvs reduced uni, see Appendix. The functionvs uni takes the unicyclic graph U and the inte-ger k = vs(T ) as input. It classifies the unicyclicgraph as one of the five cases according to the

Page 2: Vertex Separation of Unicyclic Graph

number of constituent trees with maximum ver-tex separations and their types, and analyzes eachcase individually. If vs(U) = k, it also computesan optimal layout. If vs(U) = k + 1, then thelayout L computed in Phase 1 for T is also an op-timal layout for U . In the five cases, Case 1 maymake a recursive call, but Cases 3, 4, and 5 mayinvoke the function vs reduced uni. The functionvs reduced uni takes a unicyclic graph U with twodegree 2 cycle vertices ri and rj and the integer kas input. It returns true if and only if there existsa k-conforming layout for U with respect to ri andrj(defined in [5]). As indicated in [5], the timecomplexity O(n log n) is due to the computationof function vs reduced uni and the recursive callin Case 1 of function vs uni.

In this paper, we inherit their concepts and pro-pose a new data structure, label array, to organizethe labels and layout lists of the constituent trees.The data structures can be referred to and up-dated efficiently so that the complexity of Ellis’algorithm can be improved to O(n).

2 Label and Label Array

We first recall some notations and definitionsfor trees given in [5]. In the following, ”tree” al-ways means ”rooted tree”. Let T [x] denote thesubtree rooted at x within the rooted tree T .

Definition 1 ([1]). A vertex x is k-critical in arooted tree T if and only if vs(T [x]) = k and thereare two children u and v of x such that vs(T [u]) =vs(T [v]) = k.

Definition 2 ([1]). A tree is k-critical if it con-tains a k-critical vertex.

Let T [u; v1, v2, . . . , vi] denote the tree with rootu from which the subtrees with roots v1 throughvi have been removed. The label of a rooted treeis defined as follows.

Definition 3 ([1]). For any rooted tree T [u], thelabel of u, denoted by λ(T [u]), is a list of integers(a1, a2, . . . , ap), where a1 > a2 > . . . > ap ≥ 0,and each ai is associated with a vertex vi for 1 ≤i ≤ p such that

• vs(T [u]) = a1.

• For 1 ≤ i < p, vs(T [u; v1, . . . , vi]) = ai+1.

• For 1 ≤ i < p, vi is an ai-critical vertex inT [u; v1, . . . , vi−1].

• vp = u. If ap is marked with a prime“ ′”, then there is no ap-critical vertex inT [u; v1, . . . , vp−1]; otherwise, vp is an ap-critical vertex in T [u; v1, . . . , vp−1]. In bothcases T [u; vp] = T [u;u] is the empty tree.

In particular, if |λ(T [u])| > 1, then the label ofT [u; v1] = T − T [v1] is (a2, . . . , ap).

Lemma 1 ([1]). (1) The label of a tree T rootedat u with n vertices is unique and can be com-puted in O(n) time.

(2) When |λ(T [u])| > 1, λ(T [u; v1][u]) can be ob-tained in constant time by removing the firstelement from λ(T [u]).

All rooted trees T [u] are classified into fourtypes, denoted by τ(T [u]), depending on the lo-cation of u.

Definition 4 ([1]). Let T be a tree rooted at avertex u and let k = vs(T ). The four possibletypes of T [u] are as follows:

• Type NC : u has no child v such thatvs(T [v]) = k.

• Type NCb : u has one child v such thatvs(T [v]) = k, and T is not k-critical.

• Type C : u is a k-critical vertex in T .

• Type Cb : T is k-critical and u is not a k-critical vertex.

The type of a rooted tree can be obtained fromthe labels of its root and children as follows:

1. If |λ(T [u])| > 1, then τ(T [u]) = Cb.

2. If |λ(T [u])| = 1 and without ”′ ”, thenτ(T [u]) = C.

3. If |λ(T [u])| = 1 and with “ ′ ”,

if one child of u has the same label as u,then τ(T [u]) = NCb;

otherwise, τ(T [u]) = NC.

Lemma 2. Let T be a tree rooted at u andλ(T [u]) = (a1, a2, . . . , ap) associated with verticesv1, v2, . . . , vp. The sequence (τ1, τ2, . . ., τp), whereτi = τ(T [u; v1, v2, . . ., vi−1]) for 1 ≤ i ≤ p, canbe obtained in O(n) time, where n is the vertexnumber of T .

Page 3: Vertex Separation of Unicyclic Graph

Proof. From the definition of types, τ1 = . . . =τp−1 = Cb when p > 1; and τp can bedetermined from the labels of u’s children inT [u; v1, v2, . . . , vi−1] obtained during the computa-tion of λ(T [u]), as described in [1]. Since r ≤ log nand u has at most O(n) children, the lemma fol-lows. Q.E.D.

Let U be a unicyclic graph with n verticesand r1, r2, . . . , rt be a set of cycle vertices of U .Let Ti be the constituent tree of U rooted atri, λ(Ti[ri]) = (ai

1, ai2, . . . , a

ili) associated with

vertices vi1, v

i2, . . . , v

ili, and types τ i

1, τi2, . . . , τ

ili

fori = 1, . . . , t. For each ai

j , we generate a recordRi

j = [aij , τ

ij , v

ij ]. We use a positive integer ptr∗

to store the maximum vertex separation over alllabels λ(Ti[ri]), i = 1, . . . , t. The label array ofconstituent trees Ti, i = 1, . . . , t is an array A inwhich each entry A[p],1 ≤ p ≤ ptr∗, contains

1. all records Rij with ai

j = p;

2. five integers npALL, np

NC , npNCb, n

pC , and np

Cb

such that

(a) npALL is equal to the total number of

records in A[p],

(b) npNC is equal to the total number of

records with type NC in A[p],

(c) npNCb is equal to the total number of

records with type NCb in A[p],

(d) npC is equal to the total number of

records with type C in A[p],

(e) npCb is equal to the total number of

records with type Cb in A[p];

3. a positive integer ptrp stores the maximumindex q such that 1 ≤ q < p and nq

ALL > 0.

For examples, let λ1 = (9, 8, 6, 4′) associatedwith vertices v1

1 , v12 , v1

3 , v14 , and types Cb, Cb, Cb,

NC; λ2 = (8′) associated with vertices v21 , and

types NCb; λ3 = (7, 6) associated with verticesv31 , v3

2 , and types Cb, C. Figure 1 illustrates thelabel array of Λ = {λ1, λ2, λ3}.

If Ti, i = 1, . . . , t, are all the constituent trees ofU , their label array is called the label array of Uand denoted by AU . Let T be a subgraph of U (infact it is a tree) by removing some cycle verticesand their respective constituent trees. Withoutambiguity, the label array of the constituent treesin T is referred to as the label array of T , denotedby AT .

Lemma 3. Let U be a unicyclic graph with n ver-tices.

]1[ΛA

],,6[ 32vC

],,4[ 14vNC

],,6[ 13vCb

]9[ΛA

]8[ΛA

]7[ΛA

]6[ΛA

]5[ΛA

]4[ΛA

]3[ΛA

]2[ΛA

],,7[ 31vCb

],,8[ 21vNCb],,8[ 1

2vCb

],,9[ 11vCb

iALLn i

NCn iNCbn i

Cn iCbn iptr

1

1

1

2

2

8

7

6

4

01

11

1

1 1

1

0 0 0

0 0

0

0

0

0

0

0

0

0

Figure 1: The label array of Λ = {λ1, λ2, λ3}.

(1) A label array can be constructed in O(n) time.

(2) Let e be a cycle edge of U . If vs(U − e) = kand U has one k-critical constituent tree Tc

with the k-critical vertex u(6= rc), then thelabel array of U − Tc[u] can be obtained fromthat of U in constant time.

Proof. (1) Since each element of the labels corre-sponds to a unique vertex, the total number ofelements is bounded by n. Thus, statement (1)follows.

(2) In this case, vs(U−Tc[u]) < k; and in AU [k],nk

ALL = nkCb = 1, and nk

NC = nkNCb = nk

C = 0.Thus, the label array of U −Tc[u] can be obtainedfrom AU by setting ptr∗ = ptrk, i.e., removing theentries AU [j], j > ptrk. Q.E.D.

3 Linear Time Algorithm

We insert the appropriate data structures intothe functions main, vs uni, and vs reduced uni,and update them efficiently to implement a lineartime algorithm.

Phase 1.The computation of the labels of Ti[ri], i =

1, . . . , t, and (U − e)[x], where x is an end vertexof e, and of the label array of U is inserted. FromLemma 1-(1) and Lemma 3-(1), the computationtakes O(n) time.

Phase 2.Upon calling vs uni(U, k), with the label array

of U , the case that U is in can be determined inconstant time.

In Case 1, there is only one k-critical con-stituent tree, Tc, in U . Let T ′ be the tree byremoving Tc from U . The computation in Case

Page 4: Vertex Separation of Unicyclic Graph

1 can be shown to be equivalent to that of thefollowing program segment.

Case 1: {One k-critical constituent tree}

if Tc is of type C then

if vs(T ′) = k

then return(false)else return(true);

else if vs(U − T [u]− e) < k − 1

then return(true)

else return(vs uni(U − T [u], k − 1));

If the type of Tc is C, it takes O(n) time tocompute vs(T ′) and then terminates. If the typeof Tc is Cb, the computation for updating the labelof U−e to that of U−T [u]−e and the label array ofU to that of U −T [u] is inserted. From Lemma 1-(2) and Lemma 3-(2), the updating takes constanttime. Thus, out of the recursive call, it takes onlyconstant time to determine vs(U − T [u] − e) andprepare the data structures for the recursive call.

In Case 2, the process obviously takes con-stant time, but in Cases 3, 4, and 5, it may in-voke the function vs reduced uni. Recall thatvs reduced uni takes a unicyclic graph U with twodegree 2 cycle vertices ri and rj and the integerk as input. In each of these cases, the input ofvs reduced uni is U ′ and vs(U − e), where U ′ isthe unicyclic graph yielded by removing Ti−ri andTj−rj from U for some i and j. Notice that U ′ is aunicyclic graph with two degree 2 cycle vertices ri

and rj . Let T1 and T2 be the two remaining treesafter removing ri and rj from U ′ (one of them canbe empty). Denote the vertices adjacent to ri bya and c and those adjacent to rj by b and d, wherea and b are in T1, and c and d are in T2. Note thatfor the recursive invocations in vs reduced uni, ri

and rj are fixed in each case.In the function vs uni, when ri and rj are

known, before each invocation of vs reduced uni,the computation of the labels of T1[a], T1[b], T2[c],and T2[d] and of the label arrays of constituenttrees in T1 and T2 respectively is inserted. ByLemma 1-(1) and Lemma 3-(1), the computationtakes O(n) time. In the following discussion of thefunction vs reduced uni, without loss of general-ity, assume that vs(T1) ≥ vs(T2). The discussionfor the case vs(T1) ≤ vs(T2) is similar.

In the function vs reduced uni, with the labelarrays of T1 and T2, the case that U is in can bedetermined in constant time.

The only case in which function vs reduced unirecursively calls itself is when vs(T1) = k−1, T1[a]and T1[b] are (k − 1)-critical, and T1 contains oneconstituent tree Tc of vertex separation k − 1 andof type Cb. Let u be the (k − 1)-critical vertex,which is in Tc. In this case, the problem is reducedto invoking vs reduced uni with input U − T [u]and k − 1. So, in the function vs reduced uni,the computation of the labels of (T1−T [u])[a] and(T1 − T [u])[b], and of the label array of T1 − T [u]is inserted before the recursive call. The labelof (T1 − T [u])[a] (respectively, (T1 − T [u])[b]) canbe obtained from the label of T1[a] (respectively,T1[b]) by removing its first element. The label ar-ray of T1 − T [u] can be obtained from that of T1,AT1 , by setting ptr∗ = ptrk−1. From Lemma 1-(2)and Lemma 3-(2), the computation takes constanttime.

Since there are at most O(log n) calls ofvs reduced uni and each call takes at most con-stant time, the time complexity of the invocationof vs reduced uni in function vs uni is boundedby O(log n). The time complexity of the invoca-tion of vs uni in function vs uni itself is boundedby O(n), since outside the recursive call it takesO(n) time, and there are at most O(log n) invoca-tions of vs uni, each of which takes constant time.

Thus, together with the O(n) time complexityof Phase 1, the total time complexity of the algo-rithm is O(n).

References

[1] Ellis, J. A. and Sudborough, I. H. and Turner,J. S., “The vertex separation and search num-ber of a graph,” Information and Computa-tion, 113(1): 50–79, 1994.

[2] Kirousis, Lefteris M. and Papadimitriou,Christos H., “Searching and pebbling,” The-oretical Computer Science, 47(2): 205–218,1986.

[3] Mohring, Rolf H., “Graph problems related togate matrix layout and PLA folding,” Compu-tational Graph Theory, 17–51, 1990.

[4] N. Robertson and P.D. Seymour, “Graph mi-nors I. excluding a forest,” Journal of Combi-natorial Theory. Series B, 39–61, 1983.

[5] Ellis, J. A. and Markov, M., “Computing thevertex separation of unicyclic graphs,” Infor-mation and Computation, 192: 123–161, 2004.

Page 5: Vertex Separation of Unicyclic Graph

[6] Bodlaender, Hans L. and Kloks, Ton andKratsch, Dieter, “Treewidth and pathwidth ofpermutation graphs,” SIAM Journal on Dis-crete Mathematics, 8(4): 606–616, 1995.

[7] Peng, S.-L. and Ko, M.-T. and Ho, C.-W. andHsu, T.-S. and Tang, C.-Y., “Graph searchingon some subclasses of chordal graphs,” Algo-rithmica, 27(3-4): 395–426, 2000.

[8] Bodlaender, Hans L. and Kloks, Ton, “Effi-cient and constructive algorithms for the path-width and treewidth of graphs,” Journal of Al-gorithms, 21(2): 358–402, 1996.

[9] Skodinis, K., “Construction of linear tree-layouts which are optimal with respect to ver-tex separation in linear time,” Journal of Al-gorithms, 47: 40–59, 2003.

[10] Bodlaender, Hans L. and Mohring, Rolf H.,“The pathwidth and treewidth of cographs,”SIAM Journal on Discrete Mathematics, 6(2):181–188, 1993.

Appendix

program main;

For all constituent trees, compute their vertex separationand type;

For some cycle edge e chosen at random, compute thevertex separation k; and a layout L for the tree U − e;

if vs uni(U, k)

then output (k,the layout created by vs uni)

else output (k + 1, L);

function vs uni(U : unicyclic graph, k : integer) :Boolean;

{The function assumes that vs(U − e) = k. The casesare identical to those defined in [Section 5,4], as also is thenotation}

Case 1: {One k-critical constituent tree}

if vs(T ′) = k then return(false)

else if Tc is of type C then return(true)

else compute vs(Tc − T [u]);

if vs(U−T [u]−e) < k−1 then return(true);

else return(vs uni(U − T [u], k − 1));

Case 2: {Three or more non-critical k-trees}

return(false);

Case 3: {Exactly two non-critical k-trees}

return(vs reduced uni(U ′, k));

Case 4: {Exactly one non-critical k-trees, q = numberof (k − 1)-trees, not type NC}

Case 4.1: {0 ≤ q ≤ 1}

return(true);

Case 4.2: {q = 2}

for all choices of tree Tj from among the two (k−1)-trees do

if vs reduced uni(U ′, k){where U ′ = U mi-nus the bodies of Ti and Tj}then return(true);

return(false)

Case 4.3: {q = 3}

for all choices of two trees Ti and Tj from amongthe k-tree and the three (k − 1)-trees do

if vs reduced uni(U ′, k){where U ′ = U mi-nus the bodies of Ti and Tj}then return(true);

return(false)

Case 4.4: {q ≥ 4}

return(false);

Case 5: {No k-trees, q = number of (k−1)-trees, not typeNC}

Case 5.1: {1 ≤ q ≤ 2} return(true);

Case 5.2: {q = 3}

Page 6: Vertex Separation of Unicyclic Graph

for all choices of two trees Ti and Tj from amongthe three (k − 1)-trees do

if vs reduced uni(U ′, k){where U ′ = U mi-nus the bodies of Ti and Tj}then return(true);

return(false)

Case 5.3: {q = 4}

for all choices of two trees Ti and Tj from amongthe four (k − 1)-trees do

if vs reduced uni(U ′, k){where U ′ = U mi-nus the bodies of Ti and Tj}then return(true);

return(false)

Case 5.4: {q ≥ 5}

return(false);

function vs reduced uni(U , k) : Boolean;

{The cases and the notation used are identical to thosedefined in [Section 4,4].We assume that vs(T1) ≥ vs(T2)}

Case 1: {vs(T1) = k}

return(false);

Case 2: {vs(T1) < k − 1}

return(true);

Case 3: {vs(T1) = k − 1}

if T1[a] is (k − 1)-critical and T1[b] is (k − 1)-critical

then if T1 contains one k − 1, type Cb constituent

then return(vs reduced uni(U ′, k − 1));

if T1 contains two (k − 1), type NCb constituents

then return(T2 contains only (k − 1), type NCconstituents);

if T1 contains a (k − 1), type C constituent

then return(T2 contains no k−1 types other thanNC);

else { At least one of T1[a], T1[b] is not (k− 1)-critical }

return(T1 and T2 have complementary extensibili-ties);