Old Dominion UniversityODU Digital Commons 1995 An Optimal Path Cover Algorithm for Cographs R.. and Olariu, S., "An Optimal Path Cover Algorithm for Cographs" 1995.. An optimal path cov
Trang 1Old Dominion University
ODU Digital Commons
1995
An Optimal Path Cover Algorithm for Cographs
R Lin
S Olariu
Old Dominion University
This Article is brought to you for free and open access by the Computer Science at ODU Digital Commons It has been accepted for inclusion in
Computer Science Faculty Publications by an authorized administrator of ODU Digital Commons For more information, please contact
digitalcommons@odu.edu
Repository Citation
Lin, R and Olariu, S., "An Optimal Path Cover Algorithm for Cographs" (1995) Computer Science Faculty Publications 118.
https://digitalcommons.odu.edu/computerscience_fac_pubs/118
Original Publication Citation
Lin, R., Olariu, S., & Pruesse, G (1995) An optimal path cover algorithm for cographs Computers & Mathematics with Applications,
30(8), 75-83 doi:10.1016/0898-1221(95)00139-p
Trang 2Computers Math Applic Vol 30, No 8, pp 75-83, 1995
Printed in Great Britain All rights reserved
0898-1221/95 $9.50 + 0.00 0898-1221(95)00139-$
An Optimal P a t h Cover Algorithm for Cographs*
R LIN
Department of Computer Science SUNY at Geneseo, Geneseo, NY 14454, U.S.A
S O L A R I U Department of Computer Science Old Dominion University, Norfolk, VA 23529-0162, U.S.A
G P R U E S S E Department of Computer Science and Electrical Engineering University of Vermont, Burlington, VT 05405-0156, U.S.A
(Received November 1993; accepted March 1995)
A b s t r a c t - - T h e class of cographs, or complement-reducible graphs, arises naturally in many dif- ferent areas of applied mathematics and computer science In this paper, we present an optimal algorithm for determining a minimum path cover for a cograph G In case G has a Harniltonian path (cycle) our algorithm exhibits the path (cycle) as well
K e y w o r d s - - C o g r a p h s , Scheduling, Path cover, Hamiltonicity, VLSI, Greedy algorithms, Optimal algorithms
1 I N T R O D U C T I O N
T h e graphs are a m o n g the few fundamental objects t h a t arise naturally in m a n y algorithms in
c o m p u t e r science and engineering A computational problem with a large s p e c t r u m of prac- tical applications is t h e m i n i m u m p a t h cover, which involves finding a m i n i m u m n u m b e r of vertex-disjoint p a t h s which together cover the vertices of a graph T h e p a t h cover problem finds application to d a t a b a s e design, networking, VLSI design, ring protocols, code optimization, and
m a p p i n g parallel p r o g r a m s to parallel architectures, among m a n y others A g r a p h t h a t admits
a p a t h cover of size one is referred to as Hamiltonian If the unique p a t h t h a t covers all the vertices can be extended to a cycle, the graph is said to possess a Hamiltonian cycle It is, there- fore, clear t h a t t h e m i n i m u m p a t h cover problem is at least as hard as the problem of deciding
w h e t h e r a g r a p h has a Hamiltonian p a t h (resp cycle) It is well known t h a t , as m a n y other interesting problems in graph theory, the m i n i m u m p a t h cover problem and m a n y of its variants are N P - c o m p l e t e [1]
I t is c o m m o n knowledge t h a t in spite of the fact t h a t m a n y interesting problems are N P - complete on general graphs, in practical applications one rarely has to contend with general graphs Typically, a careful analysis of the problem at hand reveals sufficient structure to limit
t h e graphs under investigation to a restricted class T h e purpose of this p a p e r is to exhibit a
*Work supported by NSF Gramts CCR-9407180, MIP-09307664, and OSR-9350450
The algorithm presented in this paper was discovered independently by the authors We would like to thank
L Stewart and D Corneil for making our cooperation possible In addition, the third author wishes to thank
D Corneil and J Edmonds for helpful discussions
75
Trang 376 R LXN et al
simple and elegant algorithm to return a minimum path cover in a class of graphs t h a t we are about to define
The cographs, or complement-reducible graphs, arise so naturally in many different area of ap- plied mathematics and computer science that their independent discovery by various researchers comes as no surprise In the literature, the cographs are also known as P4-restricted graphs [2], D*-graphs [3], SD-graphs [4], and CU-graphs [5] This class of graphs has been studied exten- sively from both the theoretical and algorithmic points of view [2-8] An early characterization [8] asserts t h a t cographs are precisely the graphs which contain no induced subgraph isomorphic to the chordless path with three edges
The class of cographs is defined recursively as follows:
• a single-vertex graph is a cograph;
• if G is a cograph, then its complement G is also a cograph;
• if G and H are cographs, then their union is also a cograph
As it turns out [8], the cographs admit a unique tree representation up to isomorphism Specif-
featuring the following
PROPERTY 1 Every internal node, except possibly for the root, has at least two children; fur- thermore, the root has only one child if, and only if, the underlying graph G is disconnected
PROPERTY 2 The internal nodes are labeled by either 0 (0-nodes) or 1 (1-nodes) in such a way
t h a t the root is always a 1-node, and such t h a t 1-nodes and 0-nodes alternate along every path
in T(G) starting at the root
Figure 1 features a cograph along with its unique tree representation
f
b
Figure 1 Illustrating a cograph and its cotree
A path cover in a graph G is a set P of paths of G t h a t contains all the vertices in G A path
refer to Figure 2: Figure 2(a) shows a possible path cover; Figure 2(b) features a minimum path cover
lem finds important applications to scheduling, VLSI, operating systems, among many others A
t h a t covers G can be extended to a cycle, G is said to possess a Hamiltonian cycle It is well
Trang 4Algorithm for Cographs 77
Figure 2 Various path covers of a graph
known t h a t the problem of determining whether a graph G has a Hamiltonian p a t h or cycle is one of the most difficult problems in computational graph theory
An algorithm to determine the hamiltonicity of cographs was given in [6] Unlike t h a t algo- rithm, the one presented here is constructive in nature In fact, we propose an algorithm that returns a minimum p a t h cover for a cograph G In case G has a path cover of size one, our algorithm exhibits a Hamiltonian path in G In case G has a Hamiltonian cycle, the unique path returned by our algorithm as a path cover for G can be augmented trivially to yield a Hamiltonian cycle
T h e remainder of this paper is organized as follows Section 2 presents the idea of our approach
in terms slightly more general t h a n the cographs; Section 3 proposes the minimum path cover algorithm for cographs along with the proof of correctness and a timing analysis; Section 4 concludes with a number of open problems
All graphs in this paper are finite with no loops or multiple edges We use standard graph
titions into nonempty, disjoint sets A and B with r = IAI < IBI = t, and such t h a t every vertex
cover for B For convenience, we enumerate the vertices of A arbitrarily as
similarly, enumerate the vertices of B as
by first writing down the vertices of pl (in the same order as they appear in Pl), followed by the vertices in P2, and so on
T h e next result establishes a property of the minimum path cover of G which will be instru- mental in our p a t h cover algorithm for cographs
THEOREM l G has a m i n i m u m p a t h c o v e r o [ s i z e m a x { l , s - r}
t h a t such a p a t h cover exists Consider removing from this path cover all the vertices in A W h a t results is a set of paths which is clearly a path cover for B
Since the removal of a vertex in A will increase the number of paths by at most one, we obtain
a p a t h cover for B of size at most k + r Now the assumption t h a t k < m a x { l , s - r} guarantees
To complete the proof of Theorem 1, we shall present an algorithm t h a t actually returns a
p a t h cover of G of size m a x ( l , s - r} In outline, our algorithm proceeds in the following two stages (Refer to Figures 3-5 for an illustration.)
Trang 578 R LINet
wll
Figure 3 Illustrating Mend and_Merge: the initial setup
THE MENDING STAGE The idea of this stage is to use vertices in A to "stitch" together disjoint paths in PB Specifically, we begin by initializing
i ~ - l , A ' ~ A , p ~ p i , andB'* B\{p~}
T h e mending stage ends when precisely one of the following conditions is satisfied:
In case the mending stage ends with A' = 0, the algorithm returns the set of paths {p, p ~ + l , , Pa } which, by our construction, is a path cover of G of size m a x { l , s - r}
If at the end of the mending stage A' is not empty, we proceed to the next stage of our algorithm For further reference we note t h a t at this point A ~ contains r - i + 1 vertices, namely vi, vi+l, • • •, yr Furthermore, B ' is the set of vertices contained in the paths Pi+l, P~+2, , Ps
THE MERGING STAGE The idea of this stage is to incorporate the vertices in A' into the set of paths {p, p ~ + l , , P8 } to create a unique path t h a t covers all the vertices of G For this purpose, consider the last r - i + 1 vertices
W t - - r d - i , W t - - r + i + l , • • • ~ W t
in the enumeration of the vertices of B specified by (2)
T h e correctness of this stage relies on the following intermediate result
belongs to A
PROOF OF LEMMA 2 To begin, note t h a t since A' is not empty, it must be the case t h a t (4) holds true Consequently, B ~ contains strictly fewer t h a n r - i + 1 vertices, implying t h a t wt-~+i belongs to the path p We distinguish between the following two cases
Trang 6Algorithm for Cographs 79
w2
W3 W4
W 7
W 8
Figure 4 Illustrating Mend_and_Merge: after the mending stage
CASE 1 i = 1
I f this is the case, t h e n no vertex in A is used to stitch together vertices in B, and so A' = A
a n d B ' = B \ {Pl} Now the assumption t h a t r = [A[ < [B I = t guarantees t h a t t - r + i _> 1
a n d so all vertices wj with j > t - r 4- i belong to B, as claimed
C A S E 2 i > 2
B y our construction, vertices vt, v 2 , , v i - 1 of A were used in the mending stage to join p a t h s in B
In particular, when vi-1 was so used, neither of conditions (3) and (4) was satisfied, implying
t h a t the set of vertices contained in the paths Pi, Pi+t, • • •, P8 contained at least r - i 4- 2 elements
On the other hand, at the end of the mending stage, the set B ~ contained fewer t h a n r - i 4- 1 elements Since v~-i was used to join p and pi, it follows t h a t all vertices wj with j > t - r 4- i
Formally, the merging stage begins by removing from the p a t h p all vertices wj with j _>
t - r 4- i 4- 1 Next, assign every vertex
• vj with 1 < j < r the label 2(j - i 4- 1);
• wj w i t h t - r + i _< j _< t the label 2(j - t + r - i) 4- 1
Trivially, after this assignment, the vertices in A ~ receive labels 2, 4, 6 , , 2(r - i 4- 1), while the vertices in B ~ receive labels 1 , 3 , , 2(r - i) 4- 1 Now consider the sequence
f f : ?£)t_rd-i, v i , ~l]t_r.t-i~-l, , V r - - l , ~lIt, Vr
obtained by merging the vertices in A' and B ' according to their labels By L e m m a 2, together with the a s s u m p t i o n t h a t every vertex in A is adjacent to all the vertices in B, it follows t h a t p ' is,
r 4 - i
Therefore, the p a t h obtained by concatenating p and p ' contains all the vertices in G T h e details are spelled out by the following procedure (Here, the procedure a p p e n d used in lines 6 and 16 works as follows: in line 6, v~ is joined to the last vertex in p and to the first vertex
Trang 780 R LIN et al
Figure 5 Illustrating Mend_and.Merge: after the merging stage
in P~+I, thus extending the path p; in line 16, the two paths p and p' are joined along their common vertex.)
P r o c e d u r e Mend_and_Merge(A, PB)
0 b e g i n
3 p ~ p,;
4 S ' ~ - B \ { p , } ;
6 p ~ a p p e n d ( p , v i , p i + l ) ;
s
9 i ~ - i + l
12 r e t u r n ( ( p , p ~ + l , ,Ps})
15 pt ~._ Wt_r+i ~ Vi~Wt_r+i+l~ ~Vr_l~l)t~Vr;
18 e n d ; {Mend_and.Merge}
COROLLARY 1.1 H r = s 1 t h e n G a d m i t s a H a m i l t o r d a n p a t h I f r > s - t h e n G a d m i t s a
H a m i l t o n i a n cycle
Trang 8Algorithm for Cographs 81 PROOF Trivially, in case r = s - 1, at the end of the mending stage, A t and B ' are both e m p t y confirming t h a t G has a Hamiltonian path In case r > s - 1, then A' is n o n e m p t y when the mending stage ends; consequently, G has a path cover of size one returned in line 16 of procedure
vertex of the path pt is in A Now the fact t h a t every vertex in A is adjacent to all the vertices
in B guarantees t h a t the edge Vr wt can be added to the concatenation of p and pt to obtain a
then the procedure Mend_and_Merge can be implemented efficiently More precisely, we maintain
information:
• a pointer to the first element of path pj;
* a pointer to the last element of p j;
• the number of elements in pj
It is easy to confirm t h a t each iteration of the mending stage takes O i l ) time if a counter for the elements in B ' is also maintained Consequently, the mending stage takes at most O([AI) time altogether
T h e merging stage starts off by removing from p all the vertices wj with j >_ t - r ÷ i + 1 This takes O ( r - i ) C O([A[) time T h e subsequent merging itself takes 21A [ - 1 operations, implying
t h a t the running time of the procedure Mend_and_Merge is bounded by O([A D To summarize our findings, we state the following result
3 A M I N I M U M P A T H C O V E R A L G O R I T H M F O R C O G R A P H S
is a binary tree, and let x be an arbitrary node of this cotree We plan to compute, recursively,
at x For this purpose, we note t h a t in case x is a leaf we return, simply, {x} By P r o p e r t y 2 and
P r o p e r t y 3 in the definition of the cotree, should x be a 0-node we only need return the union of the paths covers corresponding to its left and right subtrees, respectively
In case x is a 1-node, P r o p e r t y 3 guarantees t h a t every leaf in the left subtree of x is adjacent (as
a vertex of G) to all the leaves in the right subtree of x Now to use procedure Mend_and_Merge developed in the previous section, we only need ensure that the left subtree of x contains no more leaves t h a n its right subtree
and then proceed to swap the subtrees of every 1-node such t h a t no left subtree contains more leaves t h a n the corresponding right subtree Finally, we shrink the left subtree of every 1-node
to its root, as we are about to explain
by k - 2 identical copies of x, namely xl, x2 xk-2 in such a way that, with x0 standing for x,
* the parent of xi is x~-i whenever i > 1;
the left child of x~ is the (i + 1) st child of x in T ( G ) ;
Trang 982 R LXN et al
X ~.X 0
w
Figure 6 Illustrating t h e process of binaxizing a tree
In other words, we ensure t h a t for every 1-node, its left subtree contains at most as many leaves as the right subtree Furthermore, the left subtree of every 1-node is shrunk to its root
cover for cographs can be spelled out as follows
P r o c e d u r e FindAVlin_Path_Cover (v);
0 b e g i n
6 e n d ; {Find_Min_Path_Cover}
Find_Min_Path_Cover returns a minimum path cover of G in O(n) time
PROOF T h e correctness of the procedure follows instantly from P r o p e r t y 2, P r o p e r t y 3 together with T h e o r e m 1 To argue for the complexity, we note t h a t processing a 0-node takes O(1)
We have proposed an optimal algorithm to compute a minimum path cover for cographs
An interesting open question would be to see if a similar technique applies for the purpose
Trang 10Algorithm for Cographs 83
of determining a m i n i m u m p a t h cover for other classes of graphs related to the cographs Of particular interest are the classes of P4-reducible graphs [10] defined as graphs for which every vertex can belong to at m o s t one chordless p a t h of length three, and the class of Pa-sparse graphs [11], defined as graphs for which no set of five vertices induces more t h a n one chordless
p a t h of length three
A second direction for further research is to obtain efficient parallel algorithms to c o m p u t e a
m i n i m u m p a t h cover for cographs T h e first known a t t e m p t at solving the problem in parallel goes back to [12] Specifically, with an n-vertex cograph G represented by its cotree as input, the algorithm in [12] returns a m i n i m u m p a t h cover in a cograph in O(log2n) time using O ( n 2) processors in the Concurrent Read Concurrent Write (CRCW) P R A M I t is interesting to note
t h a t the algorithm in [12] requires O(log2n) time and O ( n 2) C R C W processors even to detect
tained an algorithm t h a t determines the number of paths in a m i n i m u m p a t h cover in O(log n)
t i m e using n / l o g n processors in the Exclusive Read Exclusive Write ( E R E W ) P R A M Con- sequently, t h e y can answer the question: "Does the graph have a Hamiltonian p a t h (cycle)?" optimally in parallel Unfortunately, the problem of exhibiting all the p a t h s in a m i n i m u m p a t h cover requires O(log2n) time and uses n / t o g n processors in the E R E W - P R A M , being subopti- mal However, the result in [13] is a considerable improvement over the algorithm in [12] b o t h in the model of c o m p u t a t i o n and in the number of processors used I t would be interesting to see if
a cost-optimal parallel algorithm for this problem can be devised To the best of our knowledge,
no such algorithm has been proposed in the literature
R E F E R E N C E S
Freeman, San Francisco, CA, (1979)
191-193 (1974)
Theory (B) 24, 125-133 (1978)
Computing 14, 926-934 (1985)
8 H Lerchs, On the clique-kernel structure of graphs, a manuscript, Department of Computer Science, Uni- versity of Toronto, (October 1972)
Mathematics 81, 79-87 (1989)
115-129 (1992)
12 G.S Adhar and S Peng, Parallel algorithm for path covering, Hamiltonian path, and Hamiltonian cycle in
364-365, (August 1990)
13 R Lin, S Olariu, J.L Schwing and J Zhang, An efficient EP~W algorithm for minimum path cover and
14 L Stewart, Cographs, a class of tree representable graphs, M.Sc Thesis, Department of Computer Science, University of Toronto, (1978, TR 126/78)