Path partition for graphs with special blocks

全文

(1)

www.elsevier.com/locate/dam

Path partition for graphs with special blocks

a

, Gerard J. Chang

b,c

aDepartment of Applied Mathematics, National Chiao Tung University, Hsinchu 30050, Taiwan bDepartment of Mathematics, National Taiwan University, Taipei 10617, Taiwan

cMathematics Division, National Center for Theoretical Sciences at Taipei, Old Mathematics Building, National Taiwan University, Taipei 10617, Taiwan

Received 8 January 2002; received in revised form 18 August 2003; accepted 18 March 2004 Available online 5 August 2004

Abstract

The path-partition problem is to ﬁnd a minimum number of vertex-disjoint paths that cover all vertices of a given graph. This paper studies the path-partition problem from an algorithmic point of view. As the Hamiltonian path problem is NP-complete for many classes of graphs, so is the path-partition problem. The main result of this paper is to present a linear-time algorithm for the path-partition problem in graphs whose blocks are complete graphs, cycles or complete bipartite graphs.

Keywords: Path partition; Block; Complete graph; Cycle; Complete bipartite graph; Algorithm

1. Introduction

A path partition of a graph is a collection of vertex-disjoint paths that cover all vertices of the graph. The path-partition problem is to ﬁnd the path-partition numberp(G) of a graph G, which is the minimum cardinality of a path partition of G. Notice that G has a Hamiltonian path if and only ifp(G)=1. Since the Hamiltonian path problem is NP-complete for planar graphs[9], bipartite graphs[10], chordal graphs[10], chordal bipartite graphs[14]and strongly chordal graphs[14], so is the path-partition problem. On the other hand, the path-partition problem is polynomially solvable for trees[11,16], interval graphs[1,2,7], circular-arc graphs[2,7], cographs[5,6,13], cocomparability graphs[8], block graphs[17–19]and bipartite distance-hereditary graphs[21]. For some references of related problems, see[3,4,12,15,20].

The purpose of this paper is to give a linear-time algorithm for the path-partition problem for graphs whose blocks are complete graphs, cycles or complete bipartite graphs. For technical reasons, we consider the following generalized problem, which is a labeling approach for the problem.

Suppose every vertexv in the graph G is associated with an integer f (v) ∈ {0, 1, 2, 3}. An f-path partition is a collection P of vertex-disjoint paths such that the following conditions hold:

(P1) Any vertexv with f (v) = 3 is in some path in P. (P2) Iff (v) = 0, then v itself is a path in P.

(P3) Iff (v) = 1, then v is an end vertex of some path in P.

Supported in part by the National Science Council under grant NSC90-2115-M002-024. 0166-218X/\$ - see front matter © 2004 Elsevier B.V. All rights reserved.

(2)

The f-path-partition problem is to determine the f-path-partition numberpf(G) which is the minimum cardinality of an f-path partition of G. It is clear thatp(G) = pf(G) when f (v) = 2 for all vertices v in G.

In the rest of this section, we review some terminology in graphs. A cut-vertex is a vertex whose removal results in a graph having more components than the original graph. A block is a maximal connected subgraph without a cut-vertex. Notice that the intersection of two distinct blocks contains at most one vertex; and a vertex is a cut-vertex if and only if it is the intersection of two or more blocks. Consequently, a graph with one or more cut-vertices has at least two blocks. An end block is a block with exactly one cut-vertex.

2. Path partition in graphs

The labeling approach used in this paper starts from the end blocks. Suppose B is an end block whose only cut-vertex is x. Let A be the graphG − (V (B) − {x}). Notice that we can view G as the “composition” of A and B, i.e., G is the union of A and

B which meet at a common vertex x. The idea is to get the path-partition number of G from those of A and B.

In the lemmas and theorems of this paper, we use the following notation. Suppose x is a speciﬁed vertex of a graph H in which

f is a vertex labeling. Fori = 0, 1, 2, 3, we deﬁne the function fi : V (H) → {0, 1, 2, 3} by fi(y) = f (y) for all vertices y except

fi(x) = i.

Lemma 1. Suppose x is a speciﬁed vertex in a graph H. Then the following statements hold.

(1) pf3(H)pf2(H)pf1(H)pf0(H). (2) pf1(H)pf0(H)pf1(H) + 1. (3) pf2(H)pf1(H)pf2(H) + 1.

(4) pf3(H) = min{pf2(H), pf(H − x)}pf(H − x) = pf0(H ) − 1. (5) pf(H)pf1(H) − 1.

Proof. (1) The inequalities follow from that anfi-path partition is anfj-path partition wheneveri < j.

(2) The second inequality follows from that replacing the path Px in anf1-path partition by two paths P and x results an f0-path partition of H.

(3) The second inequality follows from that replacing the path PxQ in anf2-path partition by two paths Px and Q results an f1-path partition of H.

(4) The ﬁrst equality follows from that one is anf3-path partition of H if and only if it is either anf2-path partition of H or an f-path partition ofH − x. The second equality follows from that P is an f0-path partition of H if and only if it is the union of{x} and an f-path partition of H − x.

(5) According to (1), (3) and (4), we have

pf(H)pf3(H ) = min{pf2(H), pf(H − x)} min{pf1(H) − 1, pf0(H) − 1} = pf1(H ) − 1.  Lemma 2. (1)pf(G) min{pf(A) + pf0(B) − 1, pf0(A) + pf(B) − 1}.

(2)pf2(G)pf1(A) + pf1(B) − 1.

Proof. (1) SupposeP is an optimal f-path partition of A, and Q an f0-path partition of B. Thenx ∈ Q and so (P ∪ Q) − {x} is an f-path partition of G. This givespf(G)pf(A) + pf0(B) − 1. Similarly, pf(G)pf0(A) + pf(B) − 1.

(2) The inequality follows from that ifP (respectively, Q) is an optimal f1-path partition of A (respectively, B) in which P x ∈ P (respectively, xQ ∈ Q) contains x, then (P ∪ Q ∪ {P xQ}) − {P x, xQ} is an f2-path partition of G. 

We now have the following theorem which is key for the inductive step of our algorithm.

Theorem 3. Suppose=pf0(B)−pf1(B) and =pf1(B)−pf2(B). (Notice that ,  ∈ {0, 1}.) Then the following statements

hold:

(1) Iff (x) = 0, then pf(G) = pf(A) + pf(B) − 1. (2) Iff (x) = 1, then pf(G) = pf1−(A) + pf(B) − 1.

(3) Iff (x)2 and  =  = 0, then pf(G) = pf(A) + pf0(B) − 1. (4) Iff (x)2 and  = 0 and  = 1, then pf(G) = pf3(A) + pf(B). (5) Iff (x)2 and  = 1, then pf(G) = pf1−(A) + pf1+(B) − 1.

(3)

Proof. SupposeP is an optimal f-path partition of G. Let P∗be the path inP that contains x. (It is possible that there is no such path whenf (x) = 3.) There are three possibilities for P∗: (a)P∗does not exist orP⊆ A; (b) P⊆ B; (c) x is an internal vertex ofP∗, sayP= P xP , withP x ⊆ A and xP ⊆ B. (The latter is possible only when f (x)2.)

For the case when (a) holds,{P ∈ P : P ⊆ A} is an f-path partition of A and {P ∈ P : P ⊆ B} ∪ {x} is an f0-path partition of B. We then have the inequality in(a ). Similarly, we have (b ) and (c ) corresponding to (b) and (c).

(a ) pf(G)pf(A) + pf0(B) − 1.

(b ) pf(G)pf0(A) + pf(B) − 1. (We may replace pf(B) by pf2(B) when f (x)2.) (c ) pf(G)pf1(A) + pf1(B) − 1. (This is possible only when f (x)2.)

We are now ready to prove the theorem.

(1) Sincef (x) = 0, we have f = f0. According to Lemma 2(1),pf(G)pf(A) + pf(B) − 1. On the other hand, (a ) and (b ) givepf(G)pf(A) + pf(B) − 1.

(2) Sincef (x) = 1, we have f = f1. Lemma 2(1), together with (a ) and (b ), givespf(G) = min{pf1(A) + pf0(B) −

1, pf0(A) + pf1(B) − 1}. If  = 0, then

pf0(A) + pf1(B) − 1pf1(A) + (pf0(B) − ) − 1 = pf1(A) + pf0(B) − 1;

and if = 1, then

pf1(A) + pf0(B) − 1(pf0(A) − 1) + (pf1(B) + ) − 1 = pf0(A) + pf1(B) − 1.

Hencepf(G) = pf1−(A) + pf(B) − 1.

(3) According to Lemma 2(1),pf(G)pf(A)+pf0(B)−1. On the other hand, as pf0(A)pf1(A)pf(A) and pf0(B)= pf1(B) = pf2(B), (a )–(c ) givepf(G)pf(A) + pf0(B) − 1.

(4) According to Lemma 1(4) and = 0 and  = 1, we have pf(B − x) = pf0(B) − 1 = pf1(B) − 1 = pf2(B).

This, together with Lemma 1(4), gives that the above value is also equal topf3(B) and so pf(B). Then, an optimal f3-path partitionP of A, together with an optimal pf-path partition ofB − x (respectively, B) when x is (respectively, is not) in a path ofP, forms an f2-path partition of G. Thus,pf(G)pf2(G)pf3(A) + pf(B).

On the other hand, sincepf1(A)pf(A)pf3(A) and pf0(B)−1=pf1(B)−1=pf(B), (a ) or (c ) impliespf(G)pf3(A)+ pf(B). Also, as pf0(A) − 1pf3(A) by Lemma 1(4), (b ) impliespf(G)pf3(A) + pf(B).

(5) According to Lemma 1(1) and Lemma 2, we have

pf(G)pf2(G) min{pf0(A) + pf2(B) − 1, pf1(A) + pf1(B) − 1}.

On the other hand, if (a ) holds, then by Lemma 1(5) and thatpf0(B) = pf1(B) + 1,

pf(G)pf(A) + pf0(B) − 1(pf1(A) − 1) + (pf1(B) + 1) − 1 = pf1(A) + pf1(B) − 1.

This, together with (b ) and (c ), gives

pf(G) = min{pf0(A) + pf2(B) − 1, pf1(A) + pf1(B) − 1}.

If = 0, then

pf0(A) + pf2(B) − 1pf1(A) + (pf1(B) − ) − 1 = pf1(A) + pf1(B) − 1;

and if = 1, then

pf1(A) + pf1(B) − 1(pf0(A) − 1) + (pf2(B) + ) − 1 = pf0(A) + pf2(B) − 1.

(4)

3. Special blocks

Notice that the inductive theorem (Theorem 3) can be applied to solve the path-partition problem on graphs for which the problem can be solved on its blocks. In this paper, we mainly consider the case when the blocks are complete graphs, cycles or complete bipartite graphs.

Now, we assume that B is a graph in which each vertexv has a label f (v) ∈ {0, 1, 2, 3}. Recall that f−1(i) is the set of

preimages of i, i.e.

f−1(i) = {v ∈ V (B) : f (v) = i}.

According to Lemma 1(4), we havepf(B) = pf(B − f−1(0)) + |f−1(0)|. Therefore, we may assume without loss of

generality thatf−1(0) = ∅ throughout this section.

We ﬁrst consider the case when B is a complete graph. The proof of the following lemma is straightforward and hence omitted.

Lemma 4. Suppose B is a complete graph. Iff−1(1) = ∅ or f−1(2) = ∅, then pf(B) = |f−1(1)|/2 else pf(B) = 1.

Next, consider the case when B is a path. This is useful as a subroutine for handling cycles. The proof of the following lemma is also omitted.

Lemma 5. Suppose B is a path.

(1) If x is an end vertex of B withf (x) = 3, then pf(B) = pf(B − x). (2) If x is an end vertex of B withf (x) = 2, then pf(B) = pf1(B).

(3) If B has an end vertex x and another vertex y withf (x) = f (y) = 1 such that no vertex between x and y has a label 1, then pf(B) = pf(B ) + 1 where B is the path obtained from B by deletingx, y and all vertices between them.

We then consider the case when B is a cycle. The proof of the following lemma is also omitted.

Lemma 6. Suppose B is a cycle.

(1) Iff−1(2) = ∅, then pf(B) = |f−1(1)|/2.

(2) If P is a path from x to y in B such thatf−1(1) ∩ P = {x, y} and f−1(2) ∩ P = ∅, then pf(B) = pf(B − P ) + 1. Finally, we consider the case when B is a complete bipartite graph withC∪D as a bipartition of the vertex set. For i ∈ {0, 1, 2, 3}, let

Ci= {u ∈ C : f (u) = i} with ci= |Ci|; Di= {v ∈ D : f (v) = i} with di= |Di|. We have the following lemmas.

Lemma 7. Ifc1= d1= 0 and c2d2andx ∈ C2, thenpf(B) = pf (B) where f is the same as f exceptf (x) = 1.

Proof. pf(B)pf (B) follows from the fact that any f -path partition of B is an f-partition.

SupposeP is an optimal f-path partition of B. We may assume that P is chosen so that the paths in P cover as few vertices as possible. For the case whenP has a path Py with y ∈ C, we may interchange y and x to assume that P x ∈ P. In this case, P is an f -path partition of B and sopf (B)pf(B). So, now assume that all end vertices of paths in P are in D. Then, these end vertices are all inD2for otherwise we may delete those end vertices inD3to get a newP which covers fewer vertices. We may further assume that paths inP cover no vertices in D3, for otherwise we may interchange such a vertex with an end vertex of a path inP and then delete it from the path. Thus each path of P uses vertices in C2∪ C3∪ D2, and has end vertices inD2. These imply thatd2> c2, contradicting thatc2d2. 

(5)

Lemma 8. Supposex ∈ C1. Also, eitherd21 with y ∈ D2, or elsec1> d1andd2= 0 < d3withy ∈ D3. Thenpf(B) = pf (B − x), where f is the same as f exceptf (y) = 1.

Proof. Suppose Py is in an optimalf -path partitionP of B − x. Then (P − {Py}) ∪ {Pyx} is an f-path partition of B and so pf(B)pf (B − x).

On the other hand, suppose Px is in an optimal f-path partitionP of B. For the case when y is not covered by any path in P, we havey ∈ D3and soc1> d1andd2= 0. Consequently, there is some Qz ∈ P with z ∈ C2∪ C3orz ∈ D3. For the former case, we replace Qz by Qzy inP; for the later, we replace Qz by Qy. So, in any case we may assume that y is covered by some path RyS inP. If RyS = P x, then again we may interchange y with the last vertex of P to assume that RyS = T yx in P for some T. IfRyS = P x, then we may replace the two paths RyS and Px by Ryx and PS. So, in any case, we may assume that P has a path Uyx. Then,(P − {Uyx}) ∪ {Uy} is an f -path partition ofB − x. Thus pf (B − x)pf(B). 

By symmetry, we may prove a similar theorem for the case whenx ∈ D1; and eitherc21 with y ∈ C2, or elsed1> c1and c2= 0 < c3withy ∈ C3.

4. Algorithm

We are ready to give a linear-time algorithm for the path-partition problem in graphs whose blocks are complete graphs, cycles or complete bipartite graphs. Notice that we may consider only connected graphs. We present ﬁve procedures. The ﬁrst four are subroutines which calculate f-path-partition numbers of complete graphs, paths, cycles and complete bipartite graphs, respectively, by using Lemmas 4–8. The last one is the main routine for the problem.

First, Lemmas 1(4) and 4 lead to the following subroutine for complete graphs.

Algorithm PCG. Find the f-path partition numberpf(B) of a complete graph B. Input. A complete graph B and a vertex labeling f.

Output.pf(B). Method. if (f−1(1) = ∅ or f−1(2) = ∅) thenpf(B) = |f−1(0)| + |f−1(1)|/2; elsepf(B) = |f−1(0)| + 1; returnpf(B).

Lemma 5 leads to the following subroutine for paths, which is useful for the cycle subroutine.

Algorithm PP. Find the f-path partition numberpf(B) of the path B. Input. A path B and a vertex labeling f withf−1(0) = ∅.

Output.pf(B). Method.

pf(B) ← 0; B ← B;

while (B = ∅) do

choose an end vertex x ofB ;

if (f (x) = 3) then B ← B − x else

choose a vertex y nearest to x withf (y) = 1

(let y be the other end vertex if there is no such vertex); pf(B) ← pf(B) + 1;

B ← B − all vertices between (and including) x and y;

end else; end while; returnpf(B).

(6)

Algorithm PC. Find the f-path partition numberpf(B) of a cycle B. Input. A cycle B and a vertex labeling f.

Output.pf(B). Method.

if (f−1(0) = ∅ and f−1(2) = ∅) thenpf(B) ← f−1(1)/2;

else if (f−1(0) = ∅ and f−1(2) = ∅ and |f−1(1)|1) then

pf(B) ← 1;

else if (f−1(0) = ∅ and f−1(2) = ∅ and |f−1(1)|2) then

choose a path P from x to y such that

f−1(1) ∩ P = {x, y} and f−1(2) ∩ P = ∅; pf(B) ← pf(B − P ) + 1 by calling PP(B − P );

else// now f−1(0) = ∅ //

letB − f−1(0) be the disjoint union of paths P1, P2, . . . , Pk; pf(B) ← |f−1(0)|;

fori = 1 to k do pf(B) ← pf(B) + pf(Pi) by calling PP(Pi);

end else; returnpf(B).

Lemmas 1(4), 7 and 8 lead to the following subroutine for complete bipartite graphs. In the subroutine, we inductively reduce the size ofC ∪ D. Besides the reduction of C0and D0in the second line, we consider 9 cases. The ﬁrst case is for C = ∅ or D = ∅. The next 5 cases are for c11 or d11. In particular, the case of c11 is covered by cases 2 and 3, except whend2= 0 and (c1d1or d3= 0). The case of d11 is covered by cases 4 and 5, except when c2= 0 and (d1c1 or c3 = 0). The exceptions are then covered by case 6. Finally, the last 3 cases are forc1= d1= 0.

Algorithm PCB. Find the f-path partition numberpf(B) of a complete bipartite graph B. Input: A complete bipartite graph B with a bipartitionC ∪ D of vertices and a vertex labeling f. Output:pf(B).

Method.

ci← |f−1(i) ∩ C| and di ← |f−1(i) ∩ D| for 0i 3; pf(B) ← c0+ d0;

while (true) do

if (c1= c2= c3= 0 or d1= d2= d3= 0) then

pf(B) ← pf(B) + c1+ c2+ d1+ d2; returnpf(B);

else if (c11 and d21) then // use Lemma 8 // c1← c1− 1; d2← d2− 1; d1← d1+ 1;

else if (c11 and c1> d1andd2= 0 < d3) then// use Lemma 8 // c1← c1− 1; d3← d3− 1; d1← d1+ 1;

else if (d11 and c21) then // use the remark after Lemma 8 // d1← d1− 1; c2← c2− 1; c1← c1+ 1;

else if (d11 and d1> c1andc2= 0 < c3) then// use the remark after Lemma 8 // d1← d1− 1; c3← c3− 1; c1← c1+ 1;

else if (c2= d2= 0 and (c1= d11 or c1> d11 with d3= 0 or d1> c11 with c3= 0)) then pf(B) ← pf(B) + max{c1, d1}; return pf(B);

else// by now c1= d1= 0 // if (c2= d2= 0) then

returnpf(B);

else if (c2d2) then// use Lemma 7 // c1← 1; c2← c2− 1;

else if (c2< d2) then// use the remark after Lemma 7 // d1← 1; d2← d2− 1;

end while.

(7)

Algorithm PG. Find the path-partition numberpf(G) of the connected graph G whose blocks are cycles, complete graphs or

complete bipartite graphs.

Input: A graph G and a vertex labeling f. Output:pf(G).

Method.

pf(G) ← 0; G ← G;

while (G = ∅) do

choose a block B ofG with only one cut-vertex x or with no cut-vertex;

if (B is a complete graph) then

ﬁndpfi(B) by calling PCG(B, fi) for 0i 3;

if (B is a cycle) then

ﬁndpfi(B) by calling PC(B, fi) for 0i 3;

if (B is a complete bipartite graph) then

ﬁndpfi(B) by calling PCB(B, fi) for 0i 3;  : =pf0(B) − pf1(B);  : =pf1(B) − pf2(B); if (f (x) = 0) then pf(G) ← pf(G) + pf(B) − 1; else if (f (x) = 1) then pf(G) ← pf(G) + pf(B) − 1; f (x) ← 1 − ; else// by now f (x) = 2 or 3 // case 1: =  = 0 pf(G) ← pf(G) + pf0(B) − 1; case 2: = 0 and  = 1 pf(G) ← pf(G) + pf(B); f (x) ← 3; case 3: = 1 pf(G) ← pf(G) + pf1+(B) − 1; f (x) ← 1 − ; G : =G − (B − {x}); end while; outputpf(G).

Theorem 9. Algorithm PG computes the f-path partition number of a connected graph whose blocks are cycles, complete graphs

or complete bipartite graphs in linear time.

Proof. The correctness of the algorithm follows from Lemma 1(4) and Lemmas 4 to 8. The algorithm takes only linear time

since depth-ﬁrst search can be used to ﬁnd end blocks and each subroutine requires onlyO(|B|) operations. 

Acknowledgements

The authors thank the referees for many constructive suggestions.

References

[1]S.R. Arikati, C. Pandu Rangan, Linear algorithm for optimal path cover problem on interval graphs, Inform. Process. Lett. 35 (1990) 149– 153.

[2]H.J. Bonuccelli, D.P. Bovet, Minimum node disjoint path covering for circular-arc graphs, Inform. P rocess. Lett. 8 (1979) 159–161. [3]G.J. Chang, Algorithmic aspects of lineark-arboricity, Taiwanese J. Math. 3 (1999) 73–81.

[4]G.J. Chang, Corrigendum for ‘The path-partition problem in block graphs’, Inform. Process. Lett. 83 (2002) 293. [5]G.J. Chang, D. Kuo, TheL(2, 1)-labeling problem on graphs, SIAM J. Discrete Math. 9 (1996) 309–316. [6]D.G. Corneil, H. Lerchs, L. Stewarts, Complement reducible graphs, Discrete Appl. Math. 3 (1981) 163–174. [7]P. Damaschke, P aths in interval graphs and circular arc graphs, Discrete Math. 112 (1993) 49–64.

[8]P. Damaschke, J.S. Deogun, D. Kratsch, G. Steiner, Finding Hamiltonian paths in cocomparability graphs using the bump number algorithm, Order 8 (1992) 383–391.

(8)

[9]M.R. Garey, D.S. Johnson, R.E. Tarjan, The planar Hamiltonian circuit problem is NP-complete, SIAM J. Comput. 5 (1976) 704–714. [10]M.C. Golumbic, Algorithmic Graph Theory and Perfect Graphs, Academic Press, New York, 1980.

[11]H.A. Jung, On a class of posets and the corresponding comparability graphs, J. Combin. Theory Ser. B 35 (1978) 125–133.

[12]Y.D. Liang, G.K. Mancher, C. Rhee, T. Mankus, in: A linear algorithm for ﬁnding Hamiltonian circuits in circular-arc graphs, 32nd ACM Southeastern Conference,1994, pp. 101–118.

[13]R. Lin, S. Olariu, G. Pruesse, An optimal path cover algorithm for cographs, Comput. Math. Appl. 30 (1995) 75–83. [14]H. Müller, Hamiltonian circuits in chordal bipartite graphs, Discrete Math. 156 (1996) 291–298.

[15]J.-J. Pan, G.J. Chang, Isometric path numbers of block graphs, submitted.

[16]Z. Skupien, Path partitions of vertices and Hamiltonicity of graphs, in: Proceedings of the Second Ozechoslovakian Symposium on Graph Theory, Prague,1974.

[17]R. Strikant, Ravi Sundaram, Karan Sher Singh, C. Pandu Rangan, Optimal path cover problem on block graphs and bipartite permutation graphs, Theoret. Comput. Sci. 115 (1993) 351–357.

[18]P.-K. Wong, Optimal path cover problem on block graphs, Theoret. Comput. Sci. 225 (1999) 163–169. [19]J.-H. Yan, G.J. Chang, The path-partition problem in block graphs, Inform. Process. Lett. 52 (1994) 317–322.

[20]J.-H. Yan, G.J. Chang, S.M. Hedetniemi, S.T. Hedetniemi,k-Path partitions in trees, Discrete Appl. Math. 78 (1997) 227–233. [21]H.-G. Yeh, G.J. Chang, The path-partition problem in bipartite distance-hereditary graphs, Taiwanese J. Math. 2 (1998) 353–360.

Updating...