DeepAI
Log In Sign Up

On Some Combinatorial Problems in Cographs

The family of graphs that can be constructed from isolated vertices by disjoint union and graph join operations are called cographs. These graphs can be represented in a tree-like representation termed parse tree or cotree. In this paper, we study some popular combinatorial problems restricted to cographs. We first present a structural characterization of minimal vertex separators in cographs. Further, we show that listing all minimal vertex separators and the complexity of some constrained vertex separators are polynomial-time solvable in cographs. We propose polynomial-time algorithms for connectivity augmentation problems and its variants in cographs, preserving the cograph property. Finally, using the dynamic programming paradigm, we present a generic framework to solve classical optimization problems such as the longest path, the Steiner path and the minimum leaf spanning tree problems restricted to cographs, our framework yields polynomial-time algorithms for all three problems.

READ FULL TEXT VIEW PDF

page 1

page 2

page 3

page 4

03/04/2021

Computing Subset Feedback Vertex Set via Leafage

Chordal graphs are characterized as the intersection graphs of subtrees ...
04/16/2020

Steiner Trees for Hereditary Graph Classes: a Treewidth Perspective

We consider the classical problems (Edge) Steiner Tree and Vertex Steine...
06/28/2021

The Reward-Penalty-Selection Problem

The Set Cover Problem (SCP) and the Hitting Set Problem (HSP) are well-s...
01/27/2023

Algorithms for ranking and unranking the combinatorial set of RNA secondary structures

In this paper, we study the combinatorial set of RNA secondary structure...
09/17/2020

Algorithms and Complexity for Variants of Covariates Fine Balance

We study here several variants of the covariates fine balance problem wh...
11/21/2017

On P_5-free Chordal bipartite graphs

A bipartite graph is chordal bipartite if every cycle of length at least...
04/18/2018

Is a Finite Intersection of Balls Covered by a Finite Union of Balls in Euclidean Spaces ?

Considering a finite intersection of balls and a finite union of other b...

1 Introduction

Many scientific problems that arise in practice can be modeled as graph theoretic problems and the solution to which can be obtained through a structural investigation of the underlying graph. Often, graphs that model scientific problems have a definite structure which inturn help in both structural and algorithmic study. Special graphs such as bipartite, chordal, planar, cographs etc., have born out of this motivation. Further, these graphs act as a candidate graph class in understanding the complexity of many classical combinatorial problems, in particular, to understand the gap between NP-complete instances and polynomial-time solvable instances.

It is important to highlight that classical problems such as MIN-VERTEX COVER, MAX-CLIQUE are NP-complete in general graphs, whereas polynomial-time solvable on chordal and cographs. It is not the case that every NP-complete problem in general graphs is polynomial-time solvable in all special graphs. For example, the Hamiltonian path, the Steiner tree and the longest path problems remain NP-complete on chordal, planar and -free graphs. For these problems, it is natural to restrict the input further and study the complexity status on subclasses of chordal, planar and -free graphs.

The focus of this paper is on cographs, also known as -free graphs (graphs that forbid induced ). Many classical problems such as STEINER TREE, HAMILTONIAN PATH, LONGEST PATH, MIN-LEAF SPANNING TREE are NP-complete on -free graphs. These results motivated us to look at the complexity status of the above problems in -free graphs (cographs).

Cographs are well studied in the literature due its simple structure and it possesses a tree-like representation. As this tree representation of cographs can be constructed in linear time [14], many classical NP-complete problems have polynomial-time algorithms restricted to cographs. For instance, HAMILTONIAN PATH (CYCLE) has a polynomial-time algorithm restricted to cographs [4]. Problems such as list coloring, induced subgraph isomorphism and weighted maximum cut remain NP-complete even in cographs.
The purpose of this paper is three fold; structural study of cographs from the minimal vertex separator perspective, using these results to present algorithms for listing all minimal vertex separators and to use these results for connectivity augmentation problems and its variants. We initiate the study of constrained vertex separators in cographs, and show that finding a minimum connected vertex separator and stable vertex separator in cographs are linear-time solvable.

For HAMILTONIAN PATH, LONGEST PATH, STEINER TREE, MIN-LEAF SPANNING TREE, using the parse tree of cographs, we present polynomial-time algorithms for all of them. All these problems have a common frame work and make use of the dynamic programming paradigm to obtain an optimum solution. Our dynamic programming paradigm works with the underlying parse tree, and designing algorithms for graphs by working with the associated tree-like representation has been looked at in [26] for partial -trees.

Given a -vertex (edge) connected graph , the vertex (edge) connectivity augmentation problems ask for a minimum number of edges to be augmented to so that the resultant graph has the specified vertex (edge) connectivity. This study was initiated by Eswaran et al. in [17] as it finds applications in the design of robust network design [32].

On the complexity front, the -vertex connectivity augmentation problem of -connected graphs is polynomial-time solvable [27]. The edge connectivity augmentation and other related problems are studied in [28, 29, 24, 23]. The algorithm of [27] runs in for arbitrary graphs and we present a linear-time algorithm for this problem in cographs. Connectivity augmentation in special graphs may not preserve the underlying structural properties and hence it is natural to ask for connectivity augmentation algorithms preserving structural properties such as planarity, chordality, -freeness. Towards this end, we shall present a linear-time algorithm for -vertex connectivity augmentation of -connected graphs in cographs preserving the cograph property.
As far as weighted version of this problem is concerned, it is NP-complete in general graphs [17, 24]. We show that weighted version has a polynomial-time algorithm in cographs. To the best of our knowledge, results presented in this paper do not appear in the literature and we believe that these results convey the message of this paper.

Road map: In Section 2, we shall present the definitions and notation used throughout our work. We shall present the structural characterization of minimal vertex separators in Section 3. In Section 4 and 5, we shall discuss algorithms for connectivity augmentation problems and its variants. Algorithms for the longest path, the Steiner path and the minimum leaf spanning tree problems are discussed in Section 6.

2 Preliminaries

We shall present graph-theoretic preliminaries first, followed by, definitions and notation related to cographs.

2.1 Graph-theoretic Preliminaries

Throughout our work, we use definitions and notation from [1] and [2]. In this paper, we work with simple, undirected and connected graphs. For a graph , let denote the vertex set and denote the edge set. Let denote the complement of the graph , where and . For an edge set , let denote the graph and denote the graph . For , and . For and , let . The degree of a vertex in , denoted as . A graph is called an induced subgraph of if for all , if and only if . For , let and denote the induced subgraph of on vertices in and , respectively. A simple path of a graph is a sequence of distinct vertices such that and is denoted by . In our work, all paths considered are simple. Denote a simple path on vertices by . For a path , let and denote the set of edges and vertices, respectively. For and and if , then denote the path . A graph is said to be connected if every pair of vertices in has a path and if the graph is not connected, it can be divided into disjoint connected components , . A connected component is said to be trivial if and non-trivial, otherwise. For a connected graph , a subset is called a vertex separator if is disconnected. A subset is called a minimal vertex separator if is a vertex separator and there does not exist a set such that is a vertex separator. A subset is called a minimum vertex separator if it is a minimal vertex separator of least size. A graph is said to be -connected if there exists a minimum vertex separator of size in .

2.2 Cograph Preliminaries

We use definitions and notation as in [3, 4, 5]. The graph that can be constructed from isolated vertices by graph join and disjoint union operations recursively is called a cograph. Also, A graph is a cograph if every induced subgraph of with at least two vertices is either disconnected or the complement to a disconnected graph. Every cograph can be represented in the form of a binary tree called parse tree and is constructed from the operations graph join and disjoint union that are used recursively to construct the cograph. Each internal node in the parse tree is labeled 1 or 0 which indicates the join (1) or union (0) operations in with respect to the child nodes of . By construction, parse tree need not be unique. A unique and normalized form of the parse tree is called cotree. For a connected cograph, the root node of the cotree is labelled 1, the children of the node labelled 1 are labelled 0, the children of the node labelled 0 are labelled 1 and so on. An example is illustrated in Figure 1. The root node of is denoted by . From the construction of , it can be observed that the set of leaf nodes in is precisely . For a node , , let denote the subgraphs induced by the leaves in the subtrees rooted at in . If is labelled 1, then for all , every vertex in is adjacent to every vertex in and if is labelled 0, then no vertex in is adjacent to any vertex in . For , let denote the cotree constructed from the cograph .

Figure 1: A tree-like representation of a cograph

3 Results on Vertex Separators

In this section, we shall present some structural results with respect to minimal vertex separators in cographs. It is known from [13] that a graph is called a cograph if and only if is -free (forbids an induced path of length of four). Using cotree representations of cographs, we shall present an algorithm for listing all minimal vertex separators in cographs and our algorithm runs in linear time. Subsequently, we shall also discuss algorithms for constrained vertex separators restricted to cographs.

Lemma 1

Let be a -connected cograph and be the -size minimal vertex separator of such that has connected components. Then, for every edge in a non-trivial component, .

Proof

Suppose is a non-trivial component in and . If, on the contrary, there exists a vertex such that and . Let be a vertex in . Clearly, the path is an induced path of length 4, contradicting the definition of cographs. Hence, the claim follows.

Definition 1

For a cograph and , a vertex is a universal vertex to , if . An edge is a universal edge to , if or .

Lemma 2

Let be a -connected cograph and be a -size minimal vertex separator in . Let be the connected components in . Then, every vertex is universal to .

Proof

It is enough to show that each vertex in is universal to each . If is trivial, then the claim is true. Suppose, is a non-trivial component in . If, on the contrary, there exists a vertex in such that is not universal to . That is, there exists a vertex in such that . Since is a minimal vertex separator there must exist in such that . Since and belongs to the same connected component , there exists a path in . By Lemma 1, . This implies that , which is a contradiction to our earlier observation. Therefore, the claim follows.

Corollary 1

Let be a -connected cograph and be a -size minimal vertex separator in . Then, every edge in is universal to .

Proof

By Lemma 2, each vertex in is universal to each . It must be the case that every edge in is universal to .

Corollary 2

Let be a -connected cograph and be a -size minimal vertex separator in . Then, each vertex in is universal to .

Proof

Follows from Lemma 1 and Corollary 1.

3.1 Listing all minimal vertex separators in cographs

We now present an algorithm to list all minimal vertex separators in cographs. Our algorithm makes use of the underlying cotree and the structural properties presented in the previous section.

1:Input: Cograph , Cotree
2:Output: All minimal vertex separators in
3: be the root of . , let denote the subgraphs induced by the leaves in the subtrees rooted at in .
4:for to
5:     .
6:     Output as a minimal vertex separator of
Algorithm 1 Enumeration of all Minimal Vertex Separators in a Cograph
Lemma 3

Given a cograph , Algorithm 1 enumerates all minimal vertex separators in .

Proof

Since is connected, the root node of is labelled . Observe that in any cotree , the children of are labelled . Further, labels alternate between and as we move down from the root to leaf. This implies that for all , is disconnected. So, any , forms a vertex separator . Note that the set , on removal leaves the graph which is disconnected as the degree of is at least 2. Observe that there does not exist a subset such that is disconnected as every vertex in is adjacent to every vertex in . So, the set output by our algorithm is minimal. Since each yields a minimal vertex separator, our algorithm prints all minimal vertex separators. Further, the algorithm runs in linear time.

3.2 Constrained vertex separators

Given a connected graph , a subset is a connected vertex separator if is a minimal vertex separator and , the graph induced on , is connected. If is an independent set (stable set), then is a stable vertex separator. It is known that finding a minimum connected vertex separator in general graphs, and in particular, in chordality 5 graphs are NP-complete [7]. In [8], it is shown that MIN-CONNECTED VERTEX SEPARATOR is polynomial-time solvable in -free graphs which are a strict subclass of chordality 5 graphs. Finding a minimum stable vertex separator in general graphs is NP-complete [9] and polynomial-time solvable restricted to triangle-free graphs and -free graphs [8]. In this paper, we shall present polynomial-time algorithms for these problems in cographs which are also a strict subclass of chordality 5 graphs.

Finding a minimum connected vertex separator:
Note that any minimum connected vertex separator contains a minimal vertex separator as a subgraph. Further, if the degree of in is at least 3, then each minimal vertex separator output by Algorithm 1 is indeed a minimum connected vertex separator in . Note that by the construction of , any two ’s is connected, and since contains at least two ’s, is connected. If the degree of is two, then , where and is any minimum vertex separator, induces a minimum connected vertex separator in . This approach, also yields all minimum connected vertex separators in , in linear time.

Finding a minimum stable vertex separator:
Observe that if the degree of is at least 3, then any minimal vertex separator in contains two ’s and hence is not stable. Therefore, if the degree of in is at least 3, then there is no stable vertex separator in . Let us consider the case where the degree of is two. Let and denote the subtrees rooted at the two children of in . A -star is a tree on vertices with one vertex having degree and the other vertices have degree one. We observe that a stable vertex separator in exists if and only if either or is a star. Clearly, the complexity of this approach is linear in the input size.

4 Vertex Connectivity Augmentation in Cographs

We shall now present algorithms for vertex connectivity augmentation in cographs. Further, we shall show that our algorithm is optimal by using lower bound arguments on the number of edges augmented. We shall work with the following notation. Let be a cograph and be its cotree. Let denote the subgraphs induced by the leaves in the subtrees rooted at in , is a child of the root node of .

4.1 -vertex connectivity augmentation

Optimum version of -vertex connectivity augmentation problem in cographs preserving the cograph property is formally defined as follows:

[frame] Instance: A -vertex connected cograph

Question: Find a minimum cardinality augmentation set such that is a

-vertex connected cograph

Lemma 4

For every such that , let be a vertex in such that is minimum. Then, any -connectivity augmentation set is such that .

Proof

From Lemma 3, we know that any minimal vertex separator is such that , for any . Since is a -connected graph, , and therefore, for any , . Note that in any -connected cograph, the size of any minimal vertex separator is at least . Therefore, to make a -connected cograph , in every , we must have so that for all , . This implies that for each in such that , we must remove a vertex from and include as a child of the root node. Due to this modification, we must augment all edges from to all vertices in . To ensure optimum, we remove from such that is minimum. Thus, any -connectivity augmentation set has atleast edges.

1:Input: -connected cograph , cotree
2:Output: -connected cograph of
3:for to
4:     if
5:          Find a vertex such that is minimum
6:          , augment the edge to and update
7:Output the augmented graph
Algorithm 2 -vertex connectivity augmentation of a cograph

Proof of correctness of Algorithm 2: In Steps 4-5, the algorithm finds all the subgraphs such that and finds a vertex such that is minimum. It further augments all the edges between and the vertices in to the augmentation set as given in Step 6. Therefore, the algorithm augments edges in total. For every in such that , let be the minimum vertex separator. Because we remove a vertex from every such , in , becomes a minimum vertex separator. Therefore, the resultant graph is a -connected cograph. Further, the algorithm runs in time.

4.2 Weighted -vertex connectivity augmentation

Optimum version of weighted -vertex connectivity augmentation problem in cographs preserving the cograph property is formally defined as follows:

[frame] Instance: A -vertex connected cograph and a weight function

Question: Find a set such that is minimum and is a

-vertex connected cograph

Lemma 5

For every such that , let be a vertex such that is minimum. Then, any weighted -connectivity augmentation set is such that .

Proof

Similar to the proof of Lemma 4, to make a -connected graph, for every such that , we remove a vertex from and include them as a child of the root node in . While doing so, we augment edges from to all the vertices in so that has vertices. To ensure optimality, is a vertex in such that is minimum and therefore, the weight of any is atleast . In , every is universal to which implies that all become the children of in . Thus, the cotree property is preserved. This completes the proof of the lemma.

1:Input: -connected cograph , cotree , weight function
2:Output: -connected cograph of
3:for to
4:     if
5:         Find a vertex such that is minimum
6:         , augment the edge to and update
7:Output the augmented graph
Algorithm 3 Weighted -vertex Connectivity Augmentation of a Cograph

Proof of correctness of Algorithm 3: In Steps 4-5, the algorithm finds all the subgraphs such that and finds a vertex such that is minimum. It further augments all the edges between and the vertices in to the augmentation set in Step 6. Therefore, the algorithm augments edges with weight . Let be the minimum vertex separator, for every in such that . Because we remove a vertex from every such , in , becomes the minimum vertex separator. In , every becomes a child of . Thus, the resultant graph is a -connected cograph and our algorithm is linear in the input size.

Remark: Results presented in Section 4.2 are a generalization of results presented in Section 4.1.

5 Edge Connectivity Augmentation in Cographs

In this section, we shall discuss two variants of edge connectivity augmentation problems in cographs. For a connected graph , a set is called an edge separator if is disconnected and is a minimum edge separator if it is an edge separator of least size. The edge connectivity of refers to the size of a minimum edge separator. A connected graph is said to be -edge connected if its edge connectivity is .

Lemma 6

Let be a cograph. Then, any minimum edge separator in is such that , where refers to the minimum degree of .

Proof

Any edge separator in a graph is obtained by removing all the edges between some and .

Case 1:

. Clearly, by removing edges incident on the minimum degree vertex, the graph is disconnected. Thus, .

Case 2:

. Let denote the cardinality of edge separator when and denote the degree of some vertex , respectively. To prove the claim, we show that . Consequently, it follows that minimum edge separator in can be obtained when . Let denote the induced subgraphs of on the leaves of the subtrees rooted at the children of the root node in . For all , let . Let and . Clearly, , where and is the th element in . Suppose . Degree of can at most be . On the contrary, assume that which implies which is a contradiction. Therefore, cardinality of the edge separator when is greater than or equal to the cardinality of the edge separator when .

Hence, size of any minimum edge separator in a cograph is . This completes the proof of the lemma.

5.1 -edge connectivity augmentation

Optimum version of -edge connectivity augmentation problem in cographs is formally defined as follows:

[frame] Instance: A -edge connected cograph

Solution: A minimum cardinality augmentation set such that is a

-edge connected graph

For a connected graph , a set of edges forms an edge cover if every vertex of is incident with at least one edge in . An edge cover with minimum cardinality is known as minimum edge cover. Let denote the cardinality of the minimum edge cover in the graph . For a disconnected graph , let be the connected components. For a trivial component , let . Then, we define .

Lemma 7

Let be a -connected cograph and let denote the set of -degree vertices in . Then, any -edge connectivity augmentation set is such that .

Proof

From Lemma 6, cardinality of any minimum edge separator is equal to . Therefore, to make a -connected graph, we must have . This implies, we must increase degree of every -degree vertex atleast by one. Removing any edge from an edge cover leaves an uncovered vertex which implies every edge in the edge cover has one vertex with degree one. Hence, every edge cover has minimum degree one. If is connected, minimum number of edges required to increase degree of every -degree vertex atleast by one is equal to . And if is disconnected, and the connected component is trivial, then we must add an edge from that vertex to some non-adjacent vertex in . If the component is non-trivial, then we must augment atleast cardinality of minimum edge cover number of edges in that component. Therefore, we must augment number of edges in total. Hence, any -edge connectivity augmentation set has atleast edges. This completes the proof of the lemma.

5.1.1 Outline of the Algorithm

Our algorithm first finds the set containing all the -degree vertices in . If is connected, it finds minimum edge cover in and adds all the edges in the edge cover to the augmentation set. If it is disconnected, it traverses through each connected component. If the connected component is trivial, it augments an edge between that vertex and some non-adjacent vertex in . If the connected component is non-trivial, it finds minimum edge cover and augments all the edges in the edge cover.

5.1.2 The Algorithm



We now present an algorithm for -edge connectivity augmentation and further prove that our algorithm is optimal.

1:Input: -connected cograph
2:Output: -connected graph of
3:Let be the set of -degree vertices in
4:if is connected then
5:     Find minimum edge cover in
6:     , augment the edge to and update
7:else
8:     for each connected component in
9:         if and then
10:             Find a vertex and augment the edge to and update
11:         else
12:             Find minimum edge cover in
13:             , augment the edge to and update
14:Output the augmented graph
Algorithm 4 -edge Connectivity Augmentation of a Cograph

5.1.3 Proof of correctness of Algorithm 4

In Step 1, the algorithm finds the set containing the set of -degree vertices in . If is connected, it finds minimum edge cover and adds all the edges to the augmentation set in Steps 4-6. This ensures degree of all vertices in is increased atleast by one. If is disconnected, it traverses through all connected components. If the component is trivial, it augments one edge from that vertex to a non-adjacent vertex in in Steps 9-10. If the component is trivial, it finds minimum edge cover in that component and adds those edges in Steps 12-13 which implies degree of all those vertices is also increased atleast by one. Since finding minimum edge cover can be done in time in cographs [12], where is the size of the parse tree, our algorithm also take time.

5.2 Weighted -edge Connectivity Augmentation

Optimal version of weighted -edge connectivity augmentation problem in cographs is formally defined as follows:

[frame] Instance: A -edge connected cograph and a weight function

Solution: An augmentation set such that is minimum and is a

-edge connected graph

For a connected weighted graph , a minimum weighted set of edges forms an minimum weighted edge cover if every vertex of is incident with at least one edge in . For the graph , let denote the weight of the minimum weighted edge cover. For a disconnected graph , let be the connected components. For a trivial component and , let , where . Then, we define .

Lemma 8

Let be a -connected cograph and let denote the set of -degree vertices in . Then, any weighted -edge connectivity augmentation set is such that .

Proof

Similar to the proof of Lemma 7, to make a -connected graph, we must increase degree of every -degree vertex atleast by one. If is connected, then to increase degree of every -degree vertex atleast by one we must augment edges with atleast weight. And if is disconnected, and the connected component is trivial, then we must add an edge with least weight from that vertex to some non-adjacent vertex in . If the component is non-trivial, then we must augment edges with atleast weight of minimum weighted edge cover in that component. Therefore, we must augment edges with total weight of . Hence, any weighted -edge connectivity augmentation set has atleast weight. This completes the proof of the lemma.

5.2.1 Outline of the Algorithm

Our algorithm first finds the set containing all the -degree vertices in . If is connected, it finds minimum weighted edge cover in and adds all the edges in the edge cover to the augmentation set. If it is disconnected, it traverses through each connected component. If the connected component is trivial, it augments an edge with minimum weight between that vertex and some non-adjacent vertex in . If the connected component is non-trivial, it finds minimum weighted edge cover and augments all the edges in the edge cover.

5.2.2 The Algorithm



We now present an algorithm for weighted -edge connectivity augmentation and further give proof of correctness of the algorithm.

1:Input: -connected cograph , weight function
2:Output: -connected graph of
3:Let be the set of -degree vertices in
4:if is connected then
5:     Find minimum weighted edge cover in
6:     , augment the edge to and update
7:else
8:     for each connected component in
9:         if and then
10:             Find a vertex and augment the edge to and update
11:         else
12:             Find minimum weighted edge cover in
13:             , augment the edge to and update
14:Output the augmented graph
Algorithm 5 Weighted -edge Connectivity Augmentation of a Cograph

5.2.3 Proof of correctness of Algorithm 5

The algorithm finds the set containing the set of -degree vertices in in Step 1. If is connected, it finds minimum weighted edge cover and adds all the edges to the augmentation set in Steps 4-6. This ensures degree of all vertices in is increased atleast by one. If is disconnected, it traverses through all connected components. If the component is trivial, it augments the edge with least weight from that vertex to a vertex in in Steps 9-10. If the component is non-trivial, it finds minimum weighted edge cover in that component and adds those edges in Steps 12-13 which implies degree of all vertices in that component is also increased atleast by one. Since minimum weighted edge cover problem is open in cographs, we use the fastest general graph minimum weighted edge cover algorithm [11] that runs in time. Thus, time complexity of Algorithm 5 is .

6 Some NP-hard Problems in Cographs

In this section, we present a generic framework using dynamic programming paradigm to solve three optimization problems; the longest path, Steiner path and minimum leaf spanning tree problems. We work with the parse tree of a cograph. The parse tree is similar to a cotree, which is a binary tree and helps in the design of dynamic programming based algorithms.

In our approach, we traverse the parse tree in post order traversal and maintain some states at each node in the parse tree which we update recursively. Our main idea is to find an optimal solution at every node in the parse tree by combining the optimal solutions of its children as we traverse the parse tree. Throughout this section, let denote the parse tree constructed from the input cograph . In each case study, the update at a node is done recursively depending upon whether is a leaf node, is labelled 0 or is labelled 1. We shall present the process in the respective sections to update the states in all the three cases. When the algorithm terminates, we have the final solution to the problem stored at the root node of the parse tree.

6.1 The Longest Path Problem

Hamiltonian path (cycle) is a well-known problem in graph theory with many practical applications in the field of computing. Given a connected graph , the Hamiltonian path (cycle) problem asks for a spanning path (cycle) in . This problem is NP-complete in general and in special graphs such as chordal graphs and chordal bipartite graphs. Polynomial-time algorithms for this problem are known in interval graphs [18], cocomparability graphs [19] and bipartite permutation graphs [20]. In this paper, we present a polynomial-time algorithm for the longest path problem which is a generalization of the Hamiltonian path problem.

For a cograph , we work with the parse tree . For a node in , denotes the subtree rooted at and denotes the underlying cograph corresponding to . We maintain two states and for every node , where is the longest path in the graph . While updating , we make use of paths generated by recursive subproblems. The paths that are not used for updating are included in which may be used later for updating ancestors of in . Let , and , denote the states w.r.t. the first and second child of , respectively in . Let denote the th vertex in the path in . The states and are updated as follows.

  1. When is a leaf node, contains the vertex and is empty.

  2. When is labelled 0, without loss of generality, let . Now, contains the path and contains the set of paths in , and . Let be the ordering of the paths in such that .

  3. When is labelled 1, without loss of generality, assume . Initialize to and assume all paths in and are uncovered initially. A path in is said to be covered if it is considered as part of update. Let and denote the number of paths uncovered in and , respectively w.r.t. . Let denote the number of vertices uncovered in w.r.t. . Firstly, we extend the path by concatenating a path in and a vertex of a path in , that is, the end point of a path in is attached to a vertex of a path in . We do this alternately (a path in and a vertex in a path of by preserving the order of vertices in the path in ) until or . Once we exhaust vertices in a path in , the next path in is considered. If , then we extend by concatenating a path in and a path in preserving the order until . Then, we extend by adding , and further extend by adding . Otherwise, we extend the path by concatenating a path in and a vertex in preserving the order until or . Similar to the above, while extending we alternate between a path in and a vertex of a path in . If , we further extend the path by including and .

  4. At the end, the update is done for the root node, which stores the longest path in the input cograph .

6.1.1 The Algorithm



We shall now present an algorithm for finding a longest path in a cograph and further prove that our algorithm is optimal.

1:Input: A cograph , parse tree
2:Output: The longest path in
3:Update is done by visiting nodes in in post order traversal
4:if is a leaf node then
5:      and
6:else
7:     /* Let , and , denote the states w.r.t. the first and second child of , respectively in . Let denote the th vertex in the path in . */
8:     if is labelled 0 then
9:          /* Assume */
10:         . Let be the ordering of the paths in such that
11:     else
12:         Initialize , , , and /* Assume */
13:         while and
14:             ; ; ;
15:             if then ; ;
16:         if then and
17:         else
18:             while and
19:                 ; ;
20:              and
21:Output , the longest path in
Algorithm 6 Longest path in a cograph

6.1.2 Proof of correctness of Algorithm 6

To show that our algorithm indeed outputs the longest path in , it is enough if we show that for every node , gives the longest path in the graph and contains the paths generated by recursive subproblems that are not used for updating . We shall prove the claim by induction on the height of , rooted at vertex .
Basis Step: When is a leaf node, the claim is true.
Induction Hypothesis: Assume that the claim is true for a parse tree of height . Let be a node at height , . Let and