Information Processing Letters 74 (2000) 129–139

Recognizing and threshold graphs through a classification of their edges

Stavros D. Nikolopoulos 1 Department of Computer Science, University of Ioannina, P.O. Box 1186, GR-45110 Ioannina, Greece

Received 24 September 1999; received in revised form 17 February 2000 Communicated by K. Iwama

Abstract In this work, we attempt to establish recognition properties and characterization for two classes of perfect graphs, namely cographs and threshold graphs, leading to constant-time parallel recognition algorithms. We classify the edges of an undirected graph as either free, semi-free or actual, and define the class of A-free graphs as the class containing all the graphs with no actual edges. Then, we define the actual subgraph Ga of a non-A-free graph G as the subgraph containing all the actual edges of G. We show properties and characterizations for the class of A-free graphs and the actual subgraph Ga of a G, and use them to derive structural and recognition properties for cographs and threshold graphs. These properties imply parallel recognition algorithms which run in O(1) time using O(nm) processors.  2000 Elsevier Science B.V. All rights reserved. Keywords: Cographs; Threshold graphs; Edge classification; Graph partition; Recognition; Parallel algorithms; Complexity

1. Introduction early 1970s by Lerchs [12] who studied their struc- tural and algorithmic properties. Lerchs has shown, Cographs (also called complement reducible among other properties (see [1,5,6,13]), the following graphs) are defined as the graphs which can be reduced two very nice algorithmic properties: to single vertices by recursively complementing all (P1) cographs are exactly the P4 restricted graphs, connected subgraphs. More precisely, the class of co- and graphs can be defined recursively as follows: (P2) cographs have a unique tree representation called (i) a single-vertex graph is a cograph; cotree. (ii) the disjoint union of a cograph is a cograph; Threshold graphs, a well-known class of perfect (iii) the complement of a cograph is a cograph. graphs, are defined as those graphs where stable sub- Cographs have arisen in many disparate areas of math- sets of their vertex sets can be distinguished by us- ematics and computer science and have been indepen- ing a single linear inequality. Equivalently, a graph dently rediscovered by various researchers under var- G = (V, E) is threshold if there exists a threshold as- ∗ ious names such as D -graphs, P4 restricted graphs, signment [α, t] consisting of a labeling α of the ver- 2-parity graphs and HD-graphs or Hereditary Dacey tices by non-negative integers and an integer threshold graphs. Cographs themselves were introduced in the t such that: (i) S is a stable set if and only if α(v1)+α(v2)+···+ 1 Email: [email protected]. α(vp) 6 t,

0020-0190/00/$ – see front matter  2000 Elsevier Science B.V. All rights reserved. PII:S0020-0190(00)00041-7 130 S.D. Nikolopoulos / Information Processing Letters 74 (2000) 129–139

where vi ∈ S, 1 6 i 6 p,andS ⊆ V . Threshold graphs their edges and obtain the actual subgraph Ga which were introduced in 1973 by Chvátal and Hammer [4]. is the subgraph of G containing all the actual edges. There are several recognition algorithms for the Based on this classification, we define the class of A- class of threshold graphs which run in linear sequen- free graphs as the class containing all the undirected tial time. On the other hand, the class of cographs graphs with no actual edges. Consequently, we prove is known to have logarithmic-time parallel recogni- that any A-free graph does not contain P4 or C4 as tion algorithms. For the class of cographs, Adhar and induced subgraphs. This implies that Peng [1] presented a parallel recognition algorithm (i) A-free graphs are a special kind of cographs, and which requires O(log2 n) time and uses O(nm) proces- (ii) a graph is threshold if and only if it is an A-free sors on a CRCW PRAM model of computation, where graph and has no induced subgraphs isomorphic n and m are the number of vertices and edges in the to 2K2. graph, respectively. Dahlhaus [7] proposed a nearly We show that G has no induced subgraph isomorphic c optimal parallel recognition algorithm which runs in to 2K2 if and only if the complement G of G is O(log2 n) time with O(n + m) processors on a CREW an A-free graph. Moreover, we show certain proper- PRAM model. Recently, He [10] published a cograph ties and characterizations for the actual subgraph Ga recognition algorithm working in O(log2 n) time with of a cograph G. Based on these results, we propose O(n + m) processors on a CREW PRAM model. It O(1)-time algorithms for recognizing A-free graphs, is worth noting that all previously known parallel al- cographs and threshold graphs using O(nm) proces- gorithms use the fact that cographs can be represented sors on a CRCW PRAM. by a unique tree (so-called cotree). This representation Throughout the paper log n denotes logarithm to the forms the base for the logarithmic time parallel recog- base two, n denotes the number of vertices and m nition [5,7,10]. As far as threshold graphs are con- denotes the number of edges in a graph. cerned, De Agostino and Petreschi [2] presented a par- allel algorithm derived from a characterization based on degrees that runs in O(log n) time with O(n/ logn) 2. Edge classification and graph partition processors on a EREW PRAM. The main technique = used for recognizing threshold graphs is the degree Let G (V, E) be an undirected simple graph with partition of the vertex set [8]. (We note that the degree n vertices and m edges. Following the notation and partition of the vertex set V of a graph G = (V, E) is terminology in [9], the neighbourhood of a vertex u of G is the set N(u)= N (u) consisting of all vertices v given by V = D0 + D1 +···+Dk where Di is the set G of all the vertices of degree δ , 0 6 i 6 k.) which are adjacent with u.Theclosed neighbourhood i [ ]= [ ]:={ }∪ In this paper we attempt to establish recognition is N u NG u u N(u). The subgraph of ⊆ [ ] properties and characterization for two classes of per- G induced by a subset S V is denoted by G S . fect graphs, namely cographs and threshold graphs, We shall use the notation NG[S](u) (respectively [ ] leading to efficient O(1)-time parallel recognition al- NG[S] u ) to denote the neighbourhood (respectively gorithms. Most of the previously proposed recognition closed neighbourhood) of a vertex u of the graph [ ] algorithms for cographs are based on a unique tree rep- G S . = resentation, while recognition algorithms for thresh- Given a graph G (V, E), we define three classes old graphs are based on a degree partition. Here, we of edges in G, denoted by AE, FE and SE according take a different approach relying on a classification to relationship of the closed neighborhoods of the = of the edges of an undirected graph and on the fact endpoints of its edges [14]. Let x (u, v) be an edge that cographs contain no induced subgraph isomorphic of G. Then, to P (see Lerchs [12]) and threshold graphs contain 4 (u, v) ∈ FE if N[u]=N[v], no induced subgraphs isomorphic to 2K2, P4,orC4 (see Chvátal and Hammer [4]). To this end, we clas- (u, v) ∈ SE if N[u]⊂N[v], sify the edges of a graph G as either free, semi-free (u, v) ∈ AE if N[u]−N[v]6=∅and or actual, according to the relationship of the closed neighborhoods of the endpoints (or end-vertices) of N[v]−N[u]6=∅. S.D. Nikolopoulos / Information Processing Letters 74 (2000) 129–139 131

Fig. 1. Three undirected graphs. Free, semi-free and actual edges are denoted by f, s and a, respectively.

Obviously the edge set E of G can be partitioned into vertices u such that the length of the shortest path from the three subsets of free edges, semi-free edges and of v to u is equal to i. actual edges, respectively; that is, E = FE + SE + AE. Given a connected graph G = (V, E) and a vertex We illustrate with three graphs G, H and I shown in v ∈ V , we define a partition L(G, v) of the vertex set Fig. 1. V (we shall frequently use the term partition of the Having classified the edges of a graph G = (V, E) graph G), with respect to the vertex v as follows: as either free, semi-free or actual, let us now define the  L(G, v) = N(v,i)| v ∈ V, 0 6 i 6 L , class of A-free graphs as follows: v 1 6 Lv < |V | , = Definition 1. An undirected graph G (V, E) is where N(v,i), 0 6 i 6 Lv,aretheadjacency-level called A-free if every edge of G is either free or semi- sets, or simply the adjacency-levels,andLv is the free edge. length of the partition L(G, v) [15]. The adjacency- level sets of the partition L(G, v) of the graph G,are By definition, a graph G is an A-free graph if and formally defined as follows: only if for every edge (x, y) of G,wehaveN[x]⊆  N(v,i)= u ∈ V | d(v,u) = i , N[y] or N[x]⊇N[y]. The graph G in Fig. 1 is an A-free graph, while the graphs H and I in the same where d(v,u) denotes the distance between vertices figure are not A-free graphs. v and u in G. We point out that d(v,u) > 0, and Let G = (V, E) be a graph which contains actual d(v,u) = 0whenv = u,foreveryv,u ∈ V . (In the edges; that is, G is not an A-free graph. We define case where G is a disconnected graph, d(v,u) =∞ the actual subgraph Ga = (Va,Ea) of the graph G as when v and w do not belong to the same connected component.) Obviously, follows:  Lv = max d(v,u) | u ∈ V , Definition 2. The graph G = (V ,E ) is called a a a N(v,0) ={v} and N(v,1) = N(v). actual subgraph of agraphG = (V, E) if Ea = AE 6 6 and Va ={v ∈ V | v is an endpoint of some edge of The adjacency-level sets N(v,i), 0 i Lv ,of L Ea},whereAE is the set of the actual edges of G and partition (G, v), can easily be computed recursively AE 6= ∅. as follows:  N(v,i)= u | (x, u) ∈ E and x ∈ N(v,i − 1) The actual subgraph G = (V ,E ) of the graph H  a a a − − ∪ − of Fig. 1 is a C (chordless cycle on 5 vertices), while N(v,i 1) N(v,i 2) , 5 6 6 the actual subgraph of the graph I of the same figure 2 i Lv 1. The set N(v,i), i > 1, contains all the using matrix multiplication; see [3]. 132 S.D. Nikolopoulos / Information Processing Letters 74 (2000) 129–139

Fig. 2. The typical structure of an A-free graph. A line between nodes Vi and Vj indicates that each vertex of node Vi is adjacent to each vertex of node Vj .

3. Structural properties of A-free graphs (i) A graph G is an A-free if and only if G − cent(G) is an A-free graph. The following results provide algorithmic proper- (ii) Let G be a connected A-free graph. Then ties for the class of A-free graphs—that is, the class of cent(G) 6= ∅. Moreover, if G − cent(G) 6= ∅,then all the undirected graphs with no actual edges. A typi- G − cent(G) contains at least two components. cal structure of an A-free graph is shown in Fig. 2. := = Let P and C denote the chordless path and the Then V1 cent(G) is not an empty set. Put G1 4 4 − = ∪ ∪···∪ chordless cycle on four vertices, respectively. Based G,andG V1 G2 G3 Gr , where each Gi − > on the definition of the actual edges of a graph, we is a component of G V1 and r 3. Then since each can easily show that the A-free graphs are exactly the Gi is an induced subgraph of G, Gi is also an A-free := 6= ∅ 6 6 graphs not having a P or C as an induced subgraph. graph, and so let Vi cent(Gi) for 1 i r. 4 4 − Thus, the following lemma holds. Since each component Gj of Gi cent(Gi ) is also an A-free graph, we can continue this procedure until we get an empty graph. Then we finally obtain the Lemma 3.1. A graph G = (V, E) is an A-free graph following partition of V(G). if and only if it contains no induced subgraph isomor- = + +···+ phic to P4 or C4. V(G) V1 V2 Vk,

where Vi = cent(Gi). Moreover we can define a = Let G (V, E) be a connected A-free graph. For partial order 6 on {V1,V2,...,Vk} as follows: convenience, we here denote by V(G)and E(G) the V 6 V if V = cent(G ) and V ⊆ V(G ). sets V and E, respectively, and define i j i i j i  It is easy to see that this partition possesses has the cent(G) = x ∈ V(G)| N[x]=V(G) . following properties.

Theorem 1 (see [11]). The following two statements Theorem 2 (see [11]). Let G be a connected A- hold. free graph, and let V(G) = V1 + V2 + ··· + Vk S.D. Nikolopoulos / Information Processing Letters 74 (2000) 129–139 133

be the partition defined above, in particular, V1 := Theorem 3 (see [6]). Let G = (V, E) be an undi- cent(G). Then this partition and the partially ordered rected graph. Then, the following statements are set ({Vi}, 6) have the following properties: equivalent: (P1) If Vi 6 Vj , then every vertex of Vi and every (i) G is a cograph; vertex of Vj are joinedS by an edge of G. (ii) G does not contain P4 as a subgraph. (P2) For every Vi , cent(G[{ Vi | Vj > Vi}]) = Vi . ∗ (P3) ForS every two Vs and Vt such that Vs 6 Vt , By Theorem 3, a graph G is a cograph or D -graph [{ | 6 6 }] G Vi Vs Vi Vt is a complete graph. if for every path in G with edges (v1,v2), (v2,v3), Moreover, forS every maximal element Vt of (v3,v4) the graph also contains the edges (v1,v3) or { } 6 [{ | 6 6 }] ( Vi , ), G Vi V1 Vi Vt is a maxi- (v2,v4) or (v1,v4) [5]. A strict subset of cographs mal complete subgraph of G. form the class of diagonal graphs or D-graphs (a strict (P4) Every edge with both endpoints in Vi is a free subset of cographs) [16]. It is important to point out edge. that Wolk [16] showed that the D-graphs are precisely (P5) Every edge with one endpoint in Vi and the other the comparability graphs of rooted trees. This result 6= endpoint in Vj ,whereVi Vj ,isasemi-free was later quoted incorrectly as “A graph without edge. induced subgraph isomorphic to P4, that is, a cograph, is the of rooted trees” [2]. The We shall refer to the structure which meets the graph C4 is a counter-example to this statement. properties of Theorem 2 as cent-tree Tc(G).Weshall Agraphisadiagonal graph or D-graph if for every call nodes the elements of a cent-tree Tc(G);thatis, path in G with edges (v1,v2), (v2,v3), (v3,v4),the the vertex sets V1,V2,...,Vk of the partition of V(G) graph also contains the edges (v1,v3) or (v2,v4) (see of an A-free graph G.Fig.2showsthecent-tree Tc(G) also [6]). Thus, the following result directly follows of an A-free graph G; all edges in a Vi are free edges, from Lemma 3.1 and Theorem 3. while all edges between nodes are semi-free edges. The cent-tree is a rooted tree with root V1;every Theorem 4.1. Let G = (V, E) be an A-free graph. node Vi of Tc(G) is either a leaf or has at least two Then, G is a cograph. children. Moreover, Vs 6 Vt if and only if Vs is an ancestor of V . t Let us now consider the case where the graph G If V and V are disjoint vertex sets of an A-free i j contains actual edges. Based on certain properties of graph G, we say that V and V are clique-adjacent i j the actual subgraph G = (V ,E ), we show some and denote V ≈ V if V 6 V or V 6 V . a a a i j i j j i characterizations of cographs leading to an efficient We point out that the property (P3) of Theorem 2 (constant-time) parallel recognition algorithm. Here- ensures that all the edges with both endpoints in a after, the adjacency-level sets of the partition L(G ,x) vertex set V are free edges, 1 6 i 6 k. A consequence a i of the graph G are denoted by N (x, i), x ∈ V and of this property is that the vertex set V ∪ V is not a a a 1 i i > 0. always a maximal clique. We can easily see that V ∪ 1 The following theorem addresses a characterization V is not a maximal clique if there exists a vertex set i of cographs which is at the heart of our parallel V such that V ≈ V , 2 6 j 6 k. j i j recognition algorithm.

= = 4. Recognition properties of cographs Lemma 4.1. Let G (V, E) be a graph and let Ga (Va,Ea) be the actual subgraph of G. The graph G is Based on the definition of cographs we can easily a cographS if and only if = see that they can be obtained from a single vertex (i) 06i62 Na(x, i) Va, and by performing a finite number of operations involving (ii) there exists no actual edge (y, z) ∈ Ea such that union and complementation (the definition is given in y,z ∈ Na(x, 2), and the introduction). Next, we present the fundamental (iii) there exists no semi-free edge (x, y) ∈ SE such theorem on cographs. that y/∈ Va, for every vertex x ∈ Va. 134 S.D. Nikolopoulos / Information Processing Letters 74 (2000) 129–139

Fig. 3. The vertical dashed lines indicate the adjacency-levels. Free and semi-free edges are denoted by f and s, respectively; all the other edges are actual edges.

Proof. (⇒)LetG = (V, E) be a cograph. Suppose edge. Then, there exists a vertex z0 such that (z, z0) ∈ E 0 that Va 6= ∅;otherwiseG is an A-free graph and, thus, and (x, z )/∈ E. There are two cases to consider. 0 0 G is a cograph (Theorem 4.1). Case I: There is no vertex x such that (x ,x)∈ E 0 ∈ (i) By Theorem 2, G does not contain P4 as and (x ,z)/E (see Fig. 4(a)). Since (x, z) is an actual 0 a subgraph. Obviously then N(x,3) =∅ for every edge, we have (y, z)∈ / E. Obviously, (y, z )/∈ E;oth- 0 x ∈ V .SinceG is a subgraph of G, N (x, 3) = erwise C4 = G[{y,x,z,z }] and, thus, y ∈ Va. Then, a a 0 ∅ for every x ∈ V . This implies, {x}∪N (x, 1) ∪ there exists a P4 path [y,x,z,z ]; a contradiction. a a 0 0 = ∈ Case II: There is a vertex x such that (x, x ) ∈ E Na(x, 2) Va for every x Va. 0 0 0 ∈ and (x ,z)∈ / E (see Fig. 4(b)). Vertices x and z are (ii) Suppose that there exists an actual edge (y, z) 0 0 ∈ connected by an edge; otherwise, [x ,x,z,z] forms Ea such that y,z Na(x, 2). Then, there exist vertices 0 0 0 ∈ 0 ∈ 0 ∈ a P4. Vertices y, z are not connected by an edge; y ,z Na(x, 2) such that (y, y ) Ea , (z, z ) Ea . 0 otherwise, y ∈ Va. If both (y, z) and (y, x ) are edges, There are three cases to consider. 0 0 0 then y ∈ Va. Therefore, we have that either [y,x,z,z ] Case I: (y, z )/∈ E and (z, y )/∈ E. Then, there 0 0 0 or [y,x,x ,z] forms a P4; a contradiction. exists a P4 path [z,y,y ,x]; a contradiction. 0 0 (⇐) Suppose that G = (V, E) is not a cograph. Case II: (y, z )/∈ E and (z, y ) ∈ E (see Fig. 3(a)). By Theorem 3 G contains a P =[v ,v ,v ,v ]. Since (y, z) is an actual edge, there exists a semi-free 4 1 2 3 4 Therefore (v ,v ) is an actual edge, and (v ,v )/∈ E, or actual edge (y, p) such that (p, z)∈ / E. Then, there 2 3 1 3 (v ,v )/∈ E and (v ,v )/∈ E. There are two cases to exists a P path [p,y,z,z0]; a contradiction. 2 4 1 4 4 consider. Case III: (y, z0) ∈ E and (z, y0) ∈ E (see Fig. 3(b)). Case I: At least one of the edges (v1,v2), (v3,v4) Since (y, z) is an actual edge, there exist semi- is a semi-free edge. Let (v1,v2) ∈ SE. In this case, free or actual edges (y, p1) and (z, q1) such that = ∈ 0 there exists a semi-free edge (v2,v1) (x, y) SE (p1,z)∈ / E and (q1,y)∈ / E. Moreover, since (y, y ) ∈ 0 such that y/Va (see Fig. 5(a)). and (z, z ) are actual edges, there exist semi-free or Case II: Both (v ,v ) and (v ,v ) are actual edges. 0 ∈ 1 2 3 4 actual edges (y, p2) and (z, q2) such that (p2,y )/ Then, there are vertices v and v such that (v ,v ) ∈ 0 ∈ 0 5 1 0 E and (q2,z)/E. Without loss of generality, we E, (v4,v5) ∈ E, (v0,v2)/∈ E and (v5,v3)/∈ E.We assume that p = p1 = p2 and q = q1 = q2.If distinguish two alternatives: ∈ [ 0 ] (x, p) / E then there exists a P4 path p,y,y ,x ;a (A1) v0 6= v5 (see Fig. 5(b)). Since P4 =[v1,v2,v3, ∈ contradiction. If (x, p) E then there exists a P4 path v4], it is easy to see that v3 ∈ Na(x, 2) and v4 ∈/ [ ] ∈ z,y,p,x ; a contradiction. The cases where (x, q) / Na(x, 1),wherex = v1. It follows that exactly E and (x, q) ∈ E follow similarly. one of the following alternatives holds: (iii) Suppose that there exists a semi-free edge (i) v3,v4 ∈ Na(x, 2), (x, y) ∈ SE such that y/∈ Va.Let(x, z) be an actual (ii) v4 ∈ Na(x, 3). S.D. Nikolopoulos / Information Processing Letters 74 (2000) 129–139 135

Fig. 4. Semi-free and actual edges are denoted by s and a, respectively.

Fig. 5. Semi-free and actual edges are denoted by s and a, respectively.

If (i) holds then there exists an actual edge joint vertex sets V = D0 +D1 +···+Dk satisfying the (v3,v4) ∈ Ea such that v3,v4 ∈ Na(x, 2). If (ii) property v ∈ Di if and only if δ(v) = i,wherev ∈ V holds then {x}∪Na(x, 1) ∪ Na(x, 2) 6= Va. and 1 6 i 6 k. Then, it uses the following result: G is (A2) v0 = v5 (see Fig. 5(c)). In this case, both (v1,v0) a threshold graph if and only if the recursions below and (v0,v4) are actual edges, and (v0,v2)/∈ E are satisfied: and (v0,v3)/∈ E (see (A1) in the case where δi+1 = δi +|Dk−i| (i = 0, 1,...,bk/2c−1), either (v0,v2) ∈ E or (v0,v3) ∈ E). Thus, there = ∈ exists an actual edge (v2,v3) (y, z) Ea such δi = δi+1 −|Dk−i| (i = k,k − 1,...,bk/2c+1). that y,z ∈ Na(x, 2),wherex = v0. 2 The approach used in this paper is different from the previous algorithm(s). Specifically, since our main 5. Recognizing threshold graphs objective is to achieve constant-time complexity for the recognition problem, we focus on forbidden sub- As stated in Section 1, there exists a sequential graphs. In other words, we focus on the problem of recognition algorithm for threshold graphs running recognizing induced subgraphs which are forbidden in O(n) time. The algorithm is based on the degree for threshold graphs. Chvátal and Hammer [4] have partition of an undirected graph and on some impor- proved the following: tant characterizations of threshold graphs presented by Chvátal and Hammer [4]. The main idea of the recog- Theorem 4 (see [4]). Let G = (V, E) be a undirected nition algorithm can be summarized as follows: Given graph. Then, the following statements are equivalent: an undirected graph G = (V, E), first, it brings to- (i) G is a threshold graph. gether all the vertices with the same degree. That is, (ii) G has no induced subgraph isomorphic to 2K2, the vertex set V of the graph is partitioned into k dis- P4,orC4. 136 S.D. Nikolopoulos / Information Processing Letters 74 (2000) 129–139

Fig. 6. The typical structure of an A-free graph which contains no induced subgraph isomorphic to 2K2. Nodes Vi,j with j = 1 contain only one vertex.

We have proved that an A-free graph contains that is |V1,1| > 1. If the subgraph induced by V1,1 is no induced subgraph isomorphic to P4 or C4 (see an A-free graph (or equivalently V1,1 is not a clique) Lemma 3.1). By combining these results with the re- then there exists at least one child of V1,1 which may sults of Theorem 4, we obtain the following theorem. contain more that one node. Let V2,1 be such a child. We continue in this way until all the children of the Theorem 5.1. The threshold graphs are precisely node Vh−1,1 are cliques (an isolate vertex is a clique); those A-free graphs containing no induced subgraph see Fig. 6. By construction, the cent-tree Tc(G) of an isomorphic to 2K2. A-free graph G has the following properties: • The vertex set K = V0,1 ∪ V1,1 ∪ ··· ∪ Vh,1 is a The following lemma gives us the conditions un- clique. der which an A-free graph G contains no induced sub- • The vertex set S = V −{V0,1 ∪ V1,1 ∪···∪Vh,1} is graph isomorphic to 2K2. We shall use Vh,k to denote an independent set. the kth node of the cent-tree Tc(G) at level h > 0; V0,1 • For every pair of nodes x,y ∈ S such that level(x) < denotes the root of Tc(G) (see Fig. 6). level(y), N(x)⊆ N(y). Let Gc = (V, Ec) be the complement of the graph G. Lemma 5.1. Let G = (V, E) be an A-free graph. The Then, K is an independent set and S is a clique in Gc. following statements are equivalent: Let (x, y) be an arbitrary edge of Gc. c (i) G has no induced subgraph isomorphic to 2K2. Case I. The edge (x, y) ∈ E has one endpoint in (ii) The complement Gc of the graph G is an A-free the set K and the other endpoint in the set S.Then graph. (x, y) is a semi-free edge. Case II. The edge (x, y) ∈ Ec has both endpoints Proof. (i) ⇒ (ii) Let G be an A-free graph and in the set S.SinceN(x) ⊆ N(y) in G,wehavethat c let Tc(G) be the cent-tree of G rooted at V0,1 := N[y]⊆N[x]. This implies that every edge in G is c cent(G). Then, level(x) = 0foreveryx ∈ V0,1.Let either free or semi-free. Thus, G is an A-free graph. V1,1,V1,2,...,V1,k1 be the children of the node V0,1. (ii) ⇒ (i) Suppose that G contains an induced c Since G contains no induced subgraph isomorphic to subgraph isomorphic to 2K2. Then, G contains an 2K2, there exists at least one child of V0,1 which may induced subgraph isomorphic to C4; a contradic- contain more that one node. Let V1,1 be such a child; tion. 2 S.D. Nikolopoulos / Information Processing Letters 74 (2000) 129–139 137

From the preceding Lemma 5.1 and Theorem 5.1 6.2. Cographs we may state the following characterization of thresh- old graphs. We now present a parallel algorithm for recognizing cographs. The algorithm is based on the results of Theorem 5.2. An undirected graph G = (V, E) is a Theorem 4.1 and Lemma 4.1. Let G = (V, E) be an threshold graph if and only if G and its complement undirected graph. By Theorem 4.1, we obtain that G Gc are A-free graphs. is a cograph if it is an A-free graph. Therefore, we have to test whether or not the edge set AE is empty. If so, The above theorem enables us to design a constant- then G is a cograph. The case where G is not an A-free time parallel recognition algorithm for threshold graph is handle by Lemma 4.1. graphs. Next, we give a more formal listing of the recogni- tion algorithm.

6. Recognition algorithms Step 1. Compute the edge sets FE, SE and AE. Step 2. If AE 6= ∅ then compute the actual subgraph Based on the results of the previous sections, Ga = (Va,Ea) of G; we present here parallel recognition algorithms for otherwise, G is A-free and, thus, G is a A-free graphs, cographs and threshold graphs. The cograph; exit. models of parallel computation used for analyzing Step 3. For every vertex x ∈ Va, do in parallel the computational complexity of each algorithm are (3.1) compute the adjacency-level sets the well-known Concurrent-Read, Concurrent-Write Na(x, 1) and Na(x, 2); PRAM (CRCW PRAM). Step 4. For every vertex x ∈ Va do in parallel (4.1) if {x}∪Na(x, 1) ∪ Na(x, 2) 6= Va then 6.1. Free graphs Cx ← false; (4.2) if there exists an actual edge (y, z) ∈ It is easy to formulate and analyze a parallel Ea: y,z ∈ Na(x, 2) then Cx ← false; algorithm for computing the classes of free, semi-free (4.3) if there exists a semi-free edge (y, z) ∈ and actual edges of a graph and, therefore, recognizing SE: y/∈ Va,thenCx ← false; whether or not a undirected graph G is an A-free graph Step 5. If Cx = true, for all vertices x ∈ Va then G is or a D-graph. We present the following results. a cograph; otherwise it is not; Theorem 6.1. The free, semi-free and actual edges of an undirected graph G with n vertices and m edges Let us now compute the time-processor complexity can be computed in O(1) time on a CRCW PRAM of the proposed parallel algorithm for recognizing using O(nm) processors. cographs. We shall use a step-by-step analysis. Corollary 6.1. A-free graphs and D-graphs can be Steps 1, 2: These steps are executed in O(1) time recognized in O(1) time with O(nm) processors on a with O(nm) processors on a CRCW PRAM (see CRCW PRAM model. Theorem 6.1). Step 3: Let G be the input graph. We recall that Remark 6.1. We assume that the input graph is the adjacency-level set N(v,i) of G can be computed connected. Otherwise, the processor complexity of the in O(1) time, if the set N(v,i − 1) is given, 0 < 2 + CRCW implementation of the algorithm is O(n i 6 Lv. For the computation of N(v,2), δv sets of nm). It is obvious that if the input graph is represented length δ are needed, where δ = max{δu | u ∈ N(v,1) by the adjacency matrix, the constant-time recognition and v ∈ V }. Therefore, the adjacency-levelP set N(v,2) of free graphs and D-graphs (also, cographs and is computed in O(1) time by using δ ∈ δv = 2 v V threshold graphs) requires at least (n ) processors, O(nm) processors. Since Ga is a subgraph of G, regardless of how many edges the graphs contain. the adjacency-level sets Na(x, 1) and Na(x, 2) are 138 S.D. Nikolopoulos / Information Processing Letters 74 (2000) 129–139

computed within the same time and processor bounds, Theorem 6.3. Threshold graphs can be recognized in for all x ∈ Va . O(1) time by using O(nm) processors on a CRCW Step 4: This step consists of substeps 4.1, 4.2 PRAM model. and 4.3. Substep 4.1: Obviously, this substep can be exe- Remark 6.1. It is easy to see that all the pro- cuted in constant time with n processors. posed recognition algorithms can also be executed in Substep 4.2: The operation of testing whether an O(logn) time by using O(nm/ logn) processors on edge is an actual edge is executed in constant time with a Concurrent-Read, Exclusive-Write PRAM (CREW one processor. Here, m0 6 m edges are tested, where PRAM) model. m0 is the number of actual edges of G. Substep 4.3: In this substep m00 6 m edges are tested, where m00 is the number of semi-free edges 7. Conclusions of G. We have presented parallel recognition algorithms In total, Step 4 is executed in constant time with for the classes of perfect graphs known as cographs O(nm) processors (see Remark 6.1). and threshold graphs. For both classes we have pro- Step 5: Here, the logical AND of O(n) Boolean posed O(1)-time recognition algorithms working with variables (bits) is computed. This computation takes O(nm) processors on a CRCW PRAM model. This constant time with O(n) processors. result implies that the following classes of perfect From the previous step-by-step analysis, we con- graphs have now constant-time parallel recognition al- clude that the algorithm runs in O(1) time with O(nm) gorithms: processors. Thus, we have the following result. • split graphs [14]; • D-graphs and A-free graphs (this paper, see also Theorem 6.2. Cographs can be recognized in O(1) [14]); timebyusingO(nm) processors on a CRCW PRAM • cographs (this paper); model. • threshold graphs (this paper). We point out that all the above O(1)-time recognition 6.3. Threshold graphs algorithms are executed with O(nm) processors. We are currently studying other graph recognition proper- ties and characterizations, still using the edge classifi- From Theorem 5.2 it is clear that we can obtain cation proposed in this paper (see also [14]). We hope a constant-time recognition algorithm for threshold our study will enable us to further extend classes of graphs. This theorem tells us that a graph G is a thresh- perfect graphs whose members can be recognized in old graph if and only if G and its complement Gc O(1) parallel time. are A-free graphs. Therefore, we obtain the following recognition algorithm: References Step 1. Compute the complement Gc of the input graph G; [1] G.S. Adhar, S. Peng, Parallel algorithms for cographs and Step 2. Test whether or not both G and Gc are A-free parity graphs with applications, J. Algorithms 11 (1990) 252– graphs; if so, G is a threshold graph. 284. [2] S. De Agostino, R. Petreschi, Parallel recognition algorithms for graphs with restricted neighborhoods, Internat. J. Found. The complement of a graph G with n vertices can Comput. Sci. 1 (1990) 123–130. 2 be computed in constant time with n processors. We [3] A. Coppersmith, S. Winogrand, Matrix multiplication via have shown that the decision whether or not a graph arithmetic progression, J. Symbolic Comput. 9 (1990) 251– G is an A-free graph can be made in constant time 280. with O(nm) processors on a CRCW PRAM model [4] V. Chvátal, P.L. Hammer, Set-patching and threshold graphs, Res. Report CORR-73-21, University of Waterloo, 1973. (see Corollary 6.1). Thus, we can present the following [5] D.G. Corneil, H. Lerchs, L. Burlingham, Complement re- result. ducible graphs, Discrete Appl. Math. 3 (1981) 163–174. S.D. Nikolopoulos / Information Processing Letters 74 (2000) 129–139 139

[6] D.G. Corneil, Y. Perl, L.K. Stewart, A linear recognition [12] H. Lerchs, On cliques and kernels, Department of Computer algorithm for cographs, SIAM J. Comput. 14 (1985) 926–934. Science, Universtity of Toronto, March 1971. [7] E. Dahlhaus, Efficient parallel recognition algorithms of [13] R. Lin, S. Olariu, An NC recognition algorithm for cographs, cographs and distance hereditary graphs, Discrete Appl. J. Parallel Distrib. Comput. 13 (1991) 76–90. Math. 57 (1995) 29–44. [14] S.D. Nikolopoulos, Constant-time parallel recognition of split [8] M.C. Golumbic, Algorithmic and Perfect graphs, Inform. Process. Lett. 54 (1995) 1–8. Graphs, Academic Press, Inc., New York, 1980. [15] S.D. Nikolopoulos, S.D. Danielopoulos, Parallel computation [9] F. Harary, Graph Theory, Addison-Wesley, Reading, MA, of perfect elimination schemes using partition techniques on 1969. triangulated graphs, Comput. Math. Appl. 29 (1995) 47–57. [10] X. He, Parallel algorithms for cographs with applications, in: [16] E.S. Wolk, The comparability graph of a tree, Proc. Amer. O. Nurmi, E. Ukkonen (Eds.), Algorithm Theory—SWAT ’92, Math. Soc. 13 (1965) 789–795. Lecture Notes in Comput. Sci., Vol. 621, Springer, Berlin, 1992, pp. 94–105. [11] M. Kano, S.D. Nikolopoulos, On the structure of A-free graphs. Part II, TR-25-99, Department of Computer Science, University of Ioannina, 1999.