Computing Optimal Leaf Roots of Chordal Cographs in Linear Time

A graph G is a k-leaf power, for an integer k>= 2, if there is a tree T with leaf set V(G) such that, for all vertices x, y in V(G), the edge xy exists in G if and only if the distance between x and y in T is at most k. Such a tree T is called a k-leaf root of G. The computational problem of constructing a k-leaf root for a given graph G and an integer k, if any, is motivated by the challenge from computational biology to reconstruct phylogenetic trees. For fixed k, Lafond [SODA 2022] recently solved this problem in polynomial time. In this paper, we propose to study optimal leaf roots of graphs G, that is, the k-leaf roots of G with minimum k value. Thus, all k'-leaf roots of G satisfy k<= k'. In terms of computational biology, seeking optimal leaf roots is more justified as they yield more probable phylogenetic trees. Lafond's result does not imply polynomial-time computability of optimal leaf roots, because, even for optimal k-leaf roots, k may (exponentially) depend on the size of G. This paper presents a linear-time construction of optimal leaf roots for chordal cographs (also known as trivially perfect graphs). Additionally, it highlights the importance of the parity of the parameter k and provides a deeper insight into the differences between optimal k-leaf roots of even versus odd k. Keywords: k-leaf power, k-leaf root, optimal k-leaf root, trivially perfect leaf power, chordal cograph


Introduction
Leaf powers have been introduced by Nishimura, Ragde and Thilikos [13] to model the phylogeny reconstruction problem from computational biology: given a graph G that represents a set of species with vertices V (G) and the interspecies similarity with edges E(G), how can we reconstruct an evolutionary tree T with a given similarity threshold k?For an integer k ≥ 2, a k-leaf root of G, a tree T with species V (G) as the leaf set and where distinct species x, y ∈ V (G) have distance at most k in T if and only if they are similar on account of xy ∈ E(G), is considered a solution to this problem.In case T exists, the graph G is called a k-leaf power.The challenge of finding a k-leaf root for given G and k has, yet, been modelled as the k-leaf power recognition problem: given G and k, decide if G has a k-leaf root.For an example, see Figure 1 with the graph G called dart.The similarities between the five species can be explained with similarity threshold k = 5 using the 5-leaf root T and with k = 4 by the 4-leaf root T ′ , both depicted in Figure 1.
For a deeper discourse into the heavily studied field of k-leaf powers, the reader is kindly referred to the survey [14].Here, we just give a short overview.
Lately, Eppstein and Havvaei [8] showed that k-leaf power recognition for graphs G with n vertices can be solved in O(f (k, ω) • n) time with f (k, ω) exponential in k and ω, the clique number of G. Quite simply put, they reduce k-leaf power recognition to the decision of a certain monadic second order property in a graph derived from G having tree-width bounded by k and ω.Lafond's even more recent algorithm [10] solves k-leaf power recognition in O(n g(k) ) time, where g(k) grows superexponentially with k.It applies sophisticated dynamic programming on a tree decomposition of G and exploits structural redundancies in G. Observe that, for fixed k, the latter method runs in polynomial time.
Before these advances, k-leaf power recognition had only been solved for all fixed k between 2 and 6.The 2-leaf powers are exactly the graphs that have just cliques as their connected components, which makes the problem trivial.For k = 3 (see [13] and [3]), k = 4 (see [13] and [4]), k = 5 (see [5]) and k = 6 (see [7]) individual algorithms have been developed, all creating a certain (tree-) decomposition of the input graph G and then attempting to fit together candidate k-leaf roots for the components into one k-leaf root for G.
A general controversial aspect of modelling the reconstruction of a phylogenetic tree T with the k-leaf power recognition problem is that k is part of the input.In the biological context, the value of k describes an upper bound on the number of evolutionary events in T that lie between two similar species x, y, thus, species adjacent in the given graph G by an edge xy.Unlike the model suggests, biologists do not always have control over the parameter k.Instead, phylogenetic trees T with as few as possible evolutionary events between all pairs of similar species are preferred.That is because, in reality, a higher number of events between x and y makes a similarity between x and y less likely.Conversely, this means that a k-leaf root of G with a small parameter k models a more probable phylogenetic tree.This paper therefore proposes a subtle change in perspective towards considering the following optimization problem.

Optimal Leaf Root (OLR)
Instance: A graph G.

Output:
An optimal leaf root T of G, that is, a κ-leaf root of G such that κ ≤ k for all k-leaf roots of G, or No, if T does not exist.
Subsequently, we use κ to indicate that the respective κ-leaf root is optimal.OLR is in a certain sense an optimization version of k-leaf power recognition.The answer No states that the given graph G is not a k-leaf power for any k and, in particular, not for the given one.Getting an optimal κ-leaf root of G helps to decide if G is a k-leaf power in many cases.A difficulty is that, for all κ and k of different parity and with 2 ≤ κ < k < 2κ − 2, there are κ-leaf powers that are not k-leaf powers [15].Then, checking κ ≤ k does not decide correctly.
As for k-leaf power recognition, there are no known general efficient solutions for OLR.If input was restricted to k-leaf powers with k ≤ K for some fixed K, we could repurpose Lafond's algorithm.Testing a given G with all 2 ≤ k ≤ K would finally reveal the minimum κ for which G is κ-leaf power.At that point, a κ-leaf root of G could also be extracted from the algorithm.But that classes of k-leaf powers have not been characterized well for any k ≥ 5 makes restricting input in the proposed way difficult.Then again, it is unknown how to decide if a given graph G is a k-leaf power for any arbitrary k.And on top of that, the minimum value κ for which a given G is a κ-leaf power, if any, may exponentially depend on the size of G.This means that this brute force searching may take exponentially or even infinitely many runs of Lafond's algorithm.
It is known that, independent of k, all k-leaf powers are strongly chordal, but not vice versa.Ptolemaic graphs are strongly chordal and a class of unbounded leaf powers.That is, there is no bound β such that every Ptolemaic graph has a k-leaf root for some k ≤ β.Nevertheless, every Ptolemaic graph on n vertices has a 2n-leaf root [1,2].Later, Theorem 5 shows that, often, this is not optimal.
This paper considers a subclass of Ptolemaic graphs, the chordal cographs, as input to OLR.By definition, chordal cographs form the intersection of the well-known chordal graphs and the cographs and, thus, they are characterized as the graphs without induced cycles on four vertices and without induced paths on four vertices [9,16,17].Golumbic [9] named this class trivially perfect graphs and also characterizes the class as the comparability graphs of rooted trees.As the approach in this paper relies on the cotree of chordal cographs for a tree model instead of the rooted tree behind the comparability graph interpretation, sticking to the former, less usual naming of the graph class is more natural here.
As a side effect of Lemma 8, this paper proves that chordal cographs are still a class of unbounded leaf powers.This means that k-leaf power recognition on this class cannot be solved in polynomial time with the algorithm of Lafond or the one of Eppstein and Havvaei.Nevertheless, the following main result of our work states that OLR can be solved in linear time for chordal cographs.
Theorem 1 Given a chordal cograph G on n vertices and m edges, a κ-leaf root of G with minimum κ can be computed in O(n + m) time.
To the best of our knowledge, chordal cographs are, thus, the first class of unbounded leaf powers with a polynomial-time solution for OLR.The linear time leaf root construction works by a divide and conquer algorithm that utilizes the cotree of the input chordal cograph G to (i) recursively identify a (universal) cut vertex u of G, (ii) divide G at u and (iii) conquer by merging recursively computed optimal leaf roots of the connected components of G − u into one optimal leaf root of G.
Please note that while, in general, an OLR-solution does not entirely work for k-leaf power recognition, as elaborated above, our OLR-approach can also be used for linear-time k-leaf power recognition on chordal cographs.The key to this is the ability of our method to solve OLR with a given parity, such that the computed κ-leaf root comes with the minimum κ of the given parity.Hence, if we choose the parity of the given k, we can tell that a given graph G is a k-leaf power if and only if the computed κ-leaf root with κ of the same parity as k satisfies κ ≤ k.
At the end of our approach, in Section 5, Theorem 10 restates our main result with the pronounced generalization of giving a desired parity as an input.The proof of Theorem 10, thus, concludes our elaborations by also showing Theorem 1.
Realizing that the desired parity of κ plays a certain role in our construction, we research this discrepancy here, and show, for certain chordal cographs, that the minimum κ can differ up to 25 percent depending on if it is wanted odd or even.The existence of κ-leaf powers that are not a k-leaf power for any opposite parity k < 2κ − 2 is shown in [15].Therefore, 100 percent is a strict upper bound on the difference between minimum odd and even similarity threshold.However, we believe that our examples in Section 6 achieve the uttermost deviation within chordal cographs.
The next section presents basic notation, definitions, and facts on trees and k-leaf powers used in this paper.The optimal leaf root construction method for chordal cographs is introduced in Section 3 and proved correct in Section 4. Section 5 provides a respective linear-time implementation, thus, proving Theorem 1.A deepened evaluation of the difference between chordal cographs with κ-leaf roots of minimum odd versus even κ is carried out in the concluding Section 6.

Preliminaries
All considered graphs are finite and without multiple edges or loops.Let G = (V, E) be a graph with vertex set V (G) = V and edge set E(G) = E.A universal vertex in G is one that is adjacent to all other vertices.If all vertices of G are universal then G is complete.A vertex x that is adjacent to exactly one other vertex of G is called a leaf and the edge containing x is a pendant edge.Two adjacent vertices x, y ∈ V (G) are true twins if xz ∈ E(G), if and only if yz ∈ E(G) for all z ∈ V (G) \ {x, y}.
The length of the x, y-path, respectively cycle, is the number of its edges, that is, n − 1 in the x, y-path and n in the cycle.If there is an x, y-path in G for all distinct x, y ∈ V (G) then G is connected.Otherwise, G is disconnected and, therefore, composed of connected components G 1 , . . ., G n , maximal induced subgraphs of G that are connected.A connected component is nontrivial if it has more than one vertex and, otherwise, it is called isolated vertex.We call Trees are the connected cycle-free graphs.This means, a tree T contains exactly one x, y-path for all x, y ∈ V (T ).
In this paper, we learn that, dependent on the given parity, the construction of an optimal leaf root differs in several details.To avoid permanent case distinctions, we use π(i) for the parity of an integer i, that is, π(i) = i mod 2.

Chordal Cographs and Cotrees
Chordal cographs, ccgs for short, are known as the graphs that are free of the path and the cycle on 4 vertices.See the top row of Figure 2 for an example ccg.One particular ccg used in this paper is the star (with t leaves), which consists of the vertices u, v 1 , . . ., v t for some t ≥ 2 and the edges uv 1 , . . ., uv t .
Like all cographs, ccgs can be represented with cotrees [6].For an example, see Figure 2. The second row shows the cotree of the example cograph in the first row.For every cograph G, the cotree T is a rooted tree with leaves V (G) and where every internal node is labelled with 0 for disjoint union or 1 for full join.In this way, the leaves define single vertex graphs and every internal node represents the cograph G combining the cographs H 1 , H 2 , . . ., H n of its children with the respective graph operation.More precisely, The cotree T is unique, can be constructed in linear time, and has the following properties: Every internal node has at least two children.
No two internal nodes with the same label, 0 or 1 , are adjacent.The subtree T X rooted at node X is the cotree of the subgraph G X induced by the leaves of T X .If X is labelled with 0 then G X is the disjoint union of the cographs represented by the children of X and if it is labelled with 1 then G X is the full join of the children cographs.
The cotree of an n-vertex cograph has at most 2n − 1 nodes.
We mostly work with ccgs without true twins, like G in Figure 2.These graphs have the following properties, as observed in the upper rows of the figure.
Proposition 2 If G is a ccg without true twins and T is the cotree of G then every node of T labelled with 1 has exactly two children, one leaf and one node labelled with 0 .
Proof: Consider any 1 -node X of T .Then X is not a leaf and, thus, has at least two children none of which a 1 -node.Since G is free of true twins, there is at most one leaf among the children of X. Distinct leaves x, y would be true twins since, by definition, both are adjacent to all z ∈ V (G) with the least common ancestor in T labelled by 1 .Because G is free of cycles on four vertices, X also has at most one 0 -child.Two distinct 0 -nodes Y, Z would represent two induced subgraphs G Y and G Z , where, by definition, G Y contained two not adjacent vertices a, b and G Z two not adjacent vertices c, d.Also by definition, there would be edges ac, ad, bc, bd in E(G) and, thus, an induced cycle on four vertices in G. Hence, X having exactly two children, one leaf and one 0 -node, is the only remaining possibility.□ Proposition 3 (Wolk [16,17]) Every connected ccg G without true twins has a unique universal vertex u and G − u is disconnected (that is, u is a cut vertex).
Proof: Because G is connected, the cotree has a 1 -root X.By Proposition 2, X has a leaf child u that, by definition, is universal in G and a 0 -child Y .Additional universal vertices would be true twins of u.By definition, G − u = G Y is disconnected and, thus, u is a cut vertex.□

Diameter, Radius and Center in Trees
Let T be a tree.The following notions are throughout used in the paper: , the cotree T of G (2nd row), an optimal (odd) 11-leaf root T of G (3rd row) as computed by Algorithm 1 (with input p = 1), and an optimal even 12-leaf root T ′ of G (bottom) as computed by Algorithm 1 with input p = 0.
The distance between two vertices x and y in T , written dist T (x, y), is the length of the unique x, y-path in T .The diameter of T , denoted diam(T ), is the maximum distance between two vertices in T , that is, diam(T ) = max{dist T (x, y) | x, y ∈ V (T )}.
A diametral path in T is a path of length diam(T ).
A vertex z is a center vertex of T if the maximum distance between z and any other vertex in T is minimum, that is, all y ∈ V (T ) satisfy max{dist The radius of T , denoted rad(T ), is the maximum distance between a center z and other vertices of For convenience, we define π(T ) = π(diam(T )), the parity of the diameter of T .It is well known for all trees T that diam(T ) = 2 • rad(T ) − π(T ) and that there is a single center vertex if π(T ) = 0 and two adjacent centers if π(T ) = 1.Furthermore, it is obvious for any diametral path in T that the end-vertices x and y are leaves and the center coincides with the center of T .Thus, we have min{dist T (z, x), dist T (z, y)} = rad(T ) − π(T ) and max{dist T (z, x), dist T (z, y)} = rad(T ) for any center vertex z of T .We call a center vertex z a min-max center of T if, for all center vertices z ′ of T , min{dist Thus, a min-max center maximizes the distance to the closest leaf of T .For a min-max center z, the leaf distance is d min The paper also requires the following technical lemma regarding the radius and the diameter of trees: ) for all 1 ≤ i < j ≤ s, if rad(T i ) = rad(T j ) then π(T i ) ≤ π(T j ), and (iii) for all 1 ≤ i < j ≤ s, rad(T i ) − π(T i ) ≥ rad(T j ) − π(T j ).
Proof: Let i < j.
(i) By definition, 2rad Finally, if just π(T j ) = 1 then the diameter of T i is even and the diameter of T j is odd, thus, not equal.This immediately tells us that and, hence, 2rad(T i ) ≥ 2rad(T j ) and we are done.

Leaf Powers, Leaf Roots and their Basic Properties
Let k ≥ 2 be an integer.A graph G is a k-leaf power if a k-leaf root T of G exists, a tree with leaves V (G) such that, for all distinct vertices x, y ∈ V (G), xy is an edge in G if and only if dist T (x, y) ≤ k.The example G in Figure 2 therefore is an 11-leaf power because of the 11-leaf root T of G in the third row and also a 12-leaf power by the 12-leaf root T ′ in the bottom row.Note that the figure shows compressed illustrations of T and T ′ where some long paths of vertices with degree two are depicted by single weighted edges.
It is well-known that a complete graph is a k-leaf power for all k ≥ 2, a graph is a k-leaf power if and only if all of its connected components are k-leaf powers, and if x, y are true twins in G then G is a k-leaf power if and only if G − x is a k-leaf power.
Note for the last fact that Lemma 7.3 and Corollary 7.4 in [12] imply the possibility to identify and remove all true twins from a graph in linear time.So, in the remainder of the paper, we can simply focus on graphs without true twins.
Since the concept of k-leaf powers is slightly different for odd and even k, we formalize this discrepancy as follows: We say that a k-leaf root is of even, respectively odd parity, if k is even, respectively odd.A k-leaf root T of G is an optimal even, respectively optimal odd leaf root if k is even, respectively odd, and all k ′ -leaf roots of G with k ′ of the same parity as leaf roots of G (independent of parity).See the third row of Figure 2 for an optimal odd leaf root T of the example graph G in the same figure and see the bottom row for an optimal even leaf root T ′ of G. Since T is an 11-leaf root and T ′ a 12-leaf root, it follows that T is an optimal leaf root of G.
We conclude this section by establishing a few properties for leaf roots as considered in this paper.The first one concerns a bound on the distance between center and leaves in T in case G is connected.
Proof: Let T be a k-leaf root of a connected graph G, and let z be a min-max center vertex of T .Let T ′ be any subtree of T − z.Then, every pair of leaf v in T ′ and leaf w outside Secondly, if G has a universal vertex u then the distance between u and the center in T cannot exceed the difference between k and the radius of T .
Proof: Consider a diametral path P in T , and let x, y be the end vertices of P .Since G is not complete, x and y are not adjacent in G. Hence, u, x and y are different leaves in T .Because T is a tree, the three paths in T , the x, u-path, the y, u-path, and P intersect at a unique (non-leaf) vertex on P , say c.

JGAA, 28(1) 243-274 (2024) 251
Let ℓ 1 be the length of the x, c-path and ℓ 2 be the length of the y, c-path in T .Since u is universal in G, we have Let z 1 , z 2 be the center vertices of T ; possibly with z 1 = z 2 , if diam(T ) is even.Recall that, since P is a diametral path, the centers of T and P coincide, and that z 1 z 2 is an edge on P whenever z 1 ̸ = z 2 .Let, without loss of generality, z 1 be on the x, z 2 -path (and so z 2 is on the y, z 1 -path).Then Since c is, like z 1 and z 2 , on the path P , either the x, z 1 -path or the y, z 2 -path contains c.Assume first that c is on the x, z 1 -path; possibly with c = z 1 .Then In the case, where c is on the y, z 2 -path, the same arguments yield dist T (u, z 2 ) ≤ k − rad(T ) and dist T (u, z 1 ) ≤ k − rad(T ) + π(T ). □ For an illustration of the lemma above, see Figure 2, where the distance of u 0 and the farthest center vertex z 0 of T satisfies dist ). Lemma 3 implies upper bounds on radius and diameter of T .
Corollary 4 If G is a graph with a universal vertex and T is a k-leaf root of G then rad(T ) ≤ k −1 and, in particular, diam(T ) ≤ 2k − 2.
Proof: Recall that k ≥ 2 by definition.Hence, for complete graphs, the statement is obvious.So, let G be a non-complete graph with universal vertex u.
As a matter of fact, k-leaf roots tend to contain long paths of vertices with degree two.It is reasonable to compress such a path P = v 0 , . . ., v n into a single weighted edge v 0 (n)v n .Clearly, weighted edges v 0 (n)v n add their weight n to distances in T and, so, dist T (v 0 , v n ) = n.

Optimal Leaf Root Construction for CCGs
The aim of this section is the development of an optimal leaf-root construction approach for ccgs G.In very simple terms, we describe a divide and conquer method that splits G into smaller ccgs G 1 , G 2 , . . ., recursively obtains their optimal leaf roots T 1 , T 2 , . . ., and then extends them into an optimal leaf root for G.
We start with introducing two basic leaf root operations and analyze their properties.The first operation, the extension of trees, is used to level the recursively found leaf roots T 1 , T 2 , . . . on the same k, which is essential for the subsequent composition into one k-leaf root.If T is a tree and δ ≥ 0 an integer then T ′ = η(T, δ) is the tree obtained from T by subdividing every pendant edge δ times, that is, replacing the edge with a new path of length δ + 1 (hence, of δ + 1 edges).The following property of this operation is well-known: Proof: Note that T and T ′ have the same set of leaves.For every two leaves u and v, we have dist The other statements are obvious from the respective definitions.□ The second operation merges the individual k-leaf roots for the connected components of a graph G into one k-leaf root T for the entire G.The goal here is to minimize the diameter of T , which, in turn, allows making optimizations to the value of k.Assume that G has s ≥ 0 non-trivial connected components G 1 , . . ., G s and t ≥ 0 isolated vertices v 1 , . . ., v t such that s + t ≥ 2 and let T 1 , . . ., T s be k-leaf roots for G 1 , . . ., G s with min-max center vertices z 1 , . . ., z s .If s > 0, we define the critical index m as the smallest element of {1, . . ., s} with d min Tm = min{d min Ti | 1 ≤ i ≤ s} and call T m the critical root.Then, the merging µ(k, T 1 , . . ., T s , v 1 , . . ., v t ) results in the tree T produced by the following steps: Notice that the µ-operation is sensitive with respect to the parity π(k).For one thing, this is necessary to guarantee that all added paths are of integer length, which is done by in-or decreasing odd k.As a side note, we point out that the lengths of added paths are also nonnegative by Lemma 2, which makes the µ-operation well-defined.On the other hand, the result is that merging works slightly different for odd and even k.For odd k, all trees T 1 , . . ., T s , including the critical one, are essentially added in the same way by our construction method.This is because, for odd k, k+π(k) The special treatment of the critical root, thus, has an effect only if k is even.Specifically in that case, we can sometimes save one in the diameter of T , if we put the critical root closer to the center of T than the rest.The reason that this optimization works is that, usually, the critical root has the largest diameter.
Lemma 5 Let G be a graph and k ≥ 2 an integer.If G is disconnected with s ≥ 0 non-trivial connected components G 1 , . . ., G s and t ≥ 0 isolated vertices v 1 , . . ., v t such that s + t ≥ 2 and if Proof: From the construction, we immediately see for all distinct vertices x and y from the same component G i that dist T (x, y) = dist Ti (x, y).Hence, dist T (x, y) ≤ k, if and only if dist Ti (x, y) ≤ k, if and only if xy is an edge in G i .
To prove that T is a k-leaf root for G, it is sufficient to show for all vertices x and y stemming from different components of G that dist T (x, y) > k.In case of s > 0, we assume, without loss of generality, that the critical index is m = 1.For the remainder of the proof, we keep in mind that, by the definition of a min-max center, dist Ti (x, z i ) − d min Ti ≥ 0 for all T i , 1 ≤ i ≤ s with min-max center z i and all leaves x of T i .
For a start, we consider a vertex x in G 1 and v j for any j ∈ {1, . . ., t} and see Similarly, for any vertex x in G i , 1 < i ≤ s, and v j , we get For any vertex x in G 1 and y in G j with 1 Similarly, for any vertex x in G i and y in G j with 1 < i < j ≤ s, we get Finally, the distance between v i and v j with 1 The two operations above simplify the description of the following leaf root construction algorithm for ccgs since they hide away many of the technical details.The foundation of the proposed recursive approach is that (i) induced subgraphs of ccgs are ccgs and (ii) every connected ccg without true twins has a unique universal cut vertex (see Proposition 3).Also, recall from Section 2.3 that true twins in graphs can be removed in linear time and, thus, be safely ignored.Therefore, we define for all ccgs G without true twins and a given parity p ∈ {0, 1} the result of the root operation ρ(G, p) as the tree T and the number k produced by the following (recursive) procedure: i.If G is a star then let u be the central vertex and v 1 , . . ., v t the leaves of G (with t ≥ 2 because G does not have true twins) 1.If p = 1 (for odd) then let T ′ = η(G, 1), obtain T by attaching a new leaf to u in T ′ , and return (T, 3). 2. If p = 0 (for even) and t = 2 then return (T, 4) with T obtained from a single vertex v by attaching the leaves u, v 1 and v 2 to v with paths of lengths one, two and three, respectively.3.If p = 0 and t > 2 then let T ′ = η(G, 2), obtain T by attaching a new leaf to u in T ′ , and return (T, 4).
ii. else if G is a connected graph then let u be the universal cut vertex of G (by Proposition 3) and let G 1 , . . ., G s be the s ≥ 1 non-trivial connected components and v 1 , . . ., v t the t ≥ 0 isolated vertices of G − u.
3. Get the extended leaf root for all i ∈ {1, . . ., s} and let . ., v t ). 4. Return (T, k) with T obtained from T ′ by attaching the leaf u to a center vertex of T ′ .iii. else G is a disconnected graph and then let G 1 , . . ., G s be the s ≥ 0 non-trivial connected components and v 1 , . . ., v t the t ≥ 0 isolated vertices of G.
Hence, if the input graph G is not a star then the approach is to firstly divide G into smaller connected subgraphs G 1 , . . ., G s (and isolated vertices v 1 , . . ., v t ), secondly find corresponding kleaf roots T 1 , . . ., T s by recursion and the η-operation, and, last, conquer by merging them into a single leaf root of G with the µ-operation.The divide step is simple for disconnected G and, otherwise, is carried out by removing the unique universal cut vertex of G.
The ρ-operation is sensitive to the given parity p for using µ as a subroutine.Observe that p also decides how the resulting k is determined.There are four cases when G is connected and not a star.In the first one, when s = 1, the construction is the same for odd and even p and consists of adding u, v 1 , . . ., v t at the correct distance to the center of T 1 and computing k from k 1 .Secondly, if s > 1 and p = 1, the µ-operation has only one way of merging the recursively found leaf roots T 1 , . . ., T s to minimize the diameter of the result T .Then, k widely depends on the two largest values of k 1 , . . ., k s .But if p = 0, there is one situation that, on the one hand, allows µ to use a smaller diameter for T by prioritizing the critical leaf root and, on the other hand, lets ρ return a slightly better value for k.This happens only when s = 2, or whenever the k c -leaf root, with k c the third-largest value among k 1 , . . ., k s , properly fits into the diametral space of T that is already required for the k a -leaf root and the k b -leaf root.
The third and bottom row of Figure 2 illustrate the results (T, 11) of ρ(G, 1) and (T ′ , 12) of ρ(G, 0) on the example G.By recursion, both are produced bottom-up, and it is difficult to follow their assembly at the deeper recursion levels.The highest recursion level of ρ(G, 1), however, has received a 7-leaf root with odd diameter for subgraph G 1 and a 5-leaf root with even diameter for G 2 in Step (ii.1.).In Step (ii.2.), the ρ-procedure determines k = k 1 + k 2 − 1 = 11.The extension of the trees in Step (ii.3.)produces the 11-leaf roots T 1 and T 2 for G 1 and G 2 , respectively, as shown in Figure 2. Their following merging and the attachment of u 0 in Step (ii.4.) produces the shown 11-leaf root T of G. Similarly, ρ(G, 0) receives an odd-diameter 8-leaf root of G 1 and an even-diameter 6-leaf root of G 2 .Since s = 2, the critical root can be treated in the special way and, thus, ρ(G, 0) determines After the extension, we get the 12-leaf roots T ′ 1 for G 1 and T ′ 2 for G 2 as in Figure 2. Their merging and the attachment of u 0 yields the 12-leaf root T ′ of G as also illustrated there.
The following statement regards the correctness of our procedure.
Theorem 5 Let G be a ccg on n vertices and without true twins and let p ∈ {0, 1}.Then (T, k) = ρ(G, p) provides a k-leaf root T of G that is optimal for parity p (hence, π(k) = p) and with The proof of the theorem above stands for the majority of the work behind this paper and it is fairly long.For readability, it has entirely been moved into the separate section that follows.
Note that, with respect to the optimality of the result, Theorem 5 makes a slightly stronger statement than our main result in Theorem 1.In fact, the ρ-operation can find a κ-leaf root with minimum κ for every ccg G simply by choosing the best from (T, k) = ρ(G, 1) and (T ′ , k ′ ) = ρ(G, 0).To prove Theorem 1, Section 5 shows how to implement the ρ-operation in linear time.

The Proof of Theorem 5
To make reading the proof of Theorem 5 easier, we break it down into the proofs of several propositions.In principle, the proof works by induction on the number of vertices and, below, we begin with the first proposition that serves the base case.
Proof: We start by observing that G does not have true twins and, thus, ρ(G, p) is well-defined.Moreover, since G is not complete, every 3-leaf root of G is an optimal (odd) leaf root and every 4-leaf root is an optimal even leaf root of G.By the same reason, any k We first consider the odd case, where k = 3 = 4 − π(k), and show that the tree T returned in Step (i.1.)is a 3-leaf root of G satisfying the claimed conditions.In fact, T is just η(G, 1) with an additional leaf attached for u.This is obviously a 3-leaf root of G with rad(T ) = 2 = k − 1 < n, diam(T ) = 4 and, thus, π(T ) = 0 and d min which settles the odd case.
In the even case, we have k = 4.If G has exactly two leaves v 1 , v 2 attached to the central vertex u then Step (i.2.) returns the tree T where the leaves u, v 1 and v 2 are attached to a vertex v with paths of lengths one, two and three, respectively.Obviously, T is a 4-leaf root of G with rad(T ) = 3 = k − 1 = n, diam(T ) = 5 and, thus, π(T ) = 1 and d min Consider the vertex w on the v 1 , v 2 -path in T ′ that is closest to v 3 and let d i = dist T ′ (v i , w) for all i ∈ {1, 2, 3}.Because of the diameter bound and since v 1 , v 2 and v 3 are pairwise non-adjacent in G, ), which implies that 3(k ′ + 1) is even.This is a contradiction to the fact that k ′ is even and, thus, the last case is settled.Thus, Proposition 6 has been shown.□ With the following proposition, we only care about non-trivial connected input graphs and, for the moment, refrain from showing the optimality of (T, k) or even Property (T3).
Proposition 7 Let G be a connected ccg on n vertices and without true twins and let p ∈ {0, 1} be a given parity.Then (T, k) = ρ(G, p) provides a k-leaf root T of G with π(k) = p and k ≤ n + 1 and satisfying (T1) and (T2).

Proof:
The proof works by induction on the number of vertices in G.The smallest connected ccg without true twins is the star with two leaves (since we ignore graphs with just one vertex).In Proposition 6, this base case has already been settled.Moreover, Proposition 6 allows to assume that G is not a larger star in the following induction step.
Next, let G have more than three vertices.Because G is connected and not a star, we are in Case ii. of the procedure for ρ.Again because G is connected and without true twins, it has a unique universal cut vertex by Proposition 3. Hence, H = G − u is disconnected.Since G is not a star, H has s ≥ 1 non-trivial connected components G 1 , . . ., G s and t ≥ 0 isolated vertices v 1 , . . ., v t such that s + t ≥ 2.
Note that, as for G, every G i is a connected ccg without true twins but with fewer vertices than G.This means that the induction hypothesis holds and, thus, Step (ii.1.)provides a k i -leaf root T i of parity p satisfying (T1) and (T2) for every G i , 1 ≤ i ≤ s.We observe that k i ≥ 3 for all i ∈ {1, . . ., s} as none of G 1 , . . ., G s is a complete graph (since they are neither isolated vertices nor contain true twins).
At this point, we assume, without loss of generality, that diam(T 1 ) ≥ diam(T 2 ) ≥ • • • ≥ diam(T s ).In addition to a simplified argumentation below, we get that This is firstly because of Lemma 1, which implies and secondly because of the induction hypothesis Next, let k be the number computed in Step (ii.2.).We observe that π(k) = p.For s = 1, the values k and k 1 differ by an even number, thus, have the same parity p.If s > 1 and p = 1 then k is the odd sum of the three odd numbers k 1 , k 2 and −1 and one even number.In the last two cases, where s > 1 and p = 0, the even value of k is the result of adding the even k 1 , the even k 2 and one more even number.Moreover, it is easy to see that k By Lemma 4 and the induction hypothesis, Step (ii.3.)produces a k-leaf root by Lemma 4 and (T2).
Then, Lemma 5 tells us that Step (ii.3.)continues by assembling a k-leaf root T ′ of H with the µoperation.Observe that, under the given assumption that diam(T 1 ) ≥ diam(T 2 ) ≥ • • • ≥ diam(T s ), the µ-operation chooses the critical index m = 1.This happens because µ uses m to select the first tree in T ′ 1 , . . ., T ′ s that minimizes d min In fact, if there was i ∈ {2, . . ., s} with π(T i ) − ki 2 < π(T 1 ) − k1 2 then we would have k 1 − k i < 2(π(T 1 ) − π(T i )).Since k 1 ≥ k i and both are of the same parity and π(T 1 ), π(T i ) ∈ {0, 1}, we could conclude that k 1 = k i and π(T 1 ) = 1 and π(T i ) = 0.But that would imply the contradiction In the following, we show that rad(T ′ ) = k − 1 ≤ n and, for that purpose, we firstly determine the diameter of T ′ .A diametral path in T ′ connects two leaves x and y, thus, vertices of H.To find the length of a diametral path, thus, the diameter of T ′ , we subsequently analyze all possible origins of x, y in H.
For leaves x and y of the same G i , 1 ≤ i ≤ s, the longest possible connecting path has length The longest path in T ′ connecting a leaf x in G 1 (recall the critical index m = 1) and y = v j , 1 ≤ j ≤ t has length Similarly, a longest path of T ′ connecting a leaf x in G i with i ∈ {2, . . ., s} and y = v j , 1 ≤ j ≤ t has length Next, let x be a leaf in G 1 (again, recall that the critical index m is 1) and y a leaf in G i with i ∈ {2, . . ., s} that are most distant from each other in T ′ .The path connecting the leaves x and y has length The leaves x in G i and y in G j with i, j ∈ {2, . . ., s} and i < j that are farthest from each other in T ′ have distance Finally, any x = v i and y Before we can determine the diameter of T ′ , we need to sort out the longest paths of T ′ from those given above.If t > 0 then we have that Moreover, in case of t ≥ 2, we also find that ≥ 0 for all i ≥ 2 by Lemma 1, It remains to compare ℓ 1,2 and ℓ 2,3 in the even case where π(k) = 0: We are now ready to estimate the diameter of T ′ and, thus, the radius.If s = 1 (and therefore Obviously, π(T ′ ) = 1 − π(T 1 ), which means that rad(T ′ ) = k − 1.Note also that, since Otherwise, if p = π(k) = 0, we first consider the case according to the considerations above.In the first case, where is even because of p = 0, and, therefore, of the same parity and because it must be the case that and, hence, rad )), we have In the other case, where we distinguish between p = 0 and p = 1.If p = 0 then k +k 1 +k 2 −3 is odd and π(T ), and we get and, thus, and we can conclude that rad(T ′ ) = k − 1 holds in every case.Similarly to the previous case, we also get and, again, k − 1 ≤ n.

JGAA, 28(1) 243-274 (2024) 261
With T ′ , the algorithm has created a k-leaf root of H = G − u with rad(T ′ ) = k − 1 ≤ n and π(k) = p.Step (ii.4.) extends T ′ to a tree T by attaching the universal vertex u of G as a leaf pendent to a center vertex of T ′ .Obviously, T is a k-leaf root of G with π(k) = p and Property (T1) Proof: With the Propositions 6 and 7, we have shown for connected input graphs G that (T, k) = ρ(G, p) returns a k-leaf root T of G with π(k) = p and that has the properties (T1) and (T2).It remains to handle disconnected input.In this case, G has s ≥ 0 non-trivial connected components G 1 , . . ., G s and t ≥ 0 isolated vertices v 1 , . . ., v t such that s + t ≥ 2.
If s = 0 then G consists of n ≥ 2 isolated vertices and, thus, Step (iii.2.) sets k = 2 for even parity and k = 3, otherwise.Then, by Lemma 5, Step (iii.3.)returns a k-leaf root T of G.
For s > 0, every G i is a connected ccg without true twins.By Proposition 7, Step (iii.1.)provides a k i -leaf root T i of parity p for every G i , 1 ≤ i ≤ s.The value assigned to k in Step (iii.Notice that, the k-leaf root T returned by ρ(G, p) for disconnected input graphs G does not need to satisfy (T1) and (T2).□ The following, last proposition finalizes the proof of Theorem 5 because it shows that the k-leaf root T returned by ρ(G, p) is optimal with respect to both the value of k and the diameter of T .
Proposition 9 Let G be a ccg without true twins and let p ∈ {0, 1} be a given parity.Then We only need to show that T fulfills (T3) for connected input graphs G and that k is always parityoptimal.
We begin with the proof of (T3) and, like for Proposition 8, this works by induction on the number of vertices in G. Again, for the base case, Proposition 6 handles the star with two leaves, the smallest connected ccg without true twins and more than one vertex.Proposition 6 settles the theorem for all stars.Now, let G have more than three vertices.That G is connected and not a star leads us to Case ii. of ρ, again.Borrowing the argumentation from the proof of Proposition 8, we immediately get that Because diam(R) ≥ ℓ 1,2 and π(R 1 ) ≥ 0 and π(R 2 ) ≥ 0, we find that In the remaining case, we have p = 0 and s > 2 and k 1 − π(T 1 ) = k 3 − π(T 3 ).Like in the proof of Proposition 7, we can conclude that Here, we show that at least one of the three length for all j ∈ {1, 2, 3} \ {i} and we are done, already.Therefore, consider that diam(R i ) + π(R i ) ≤ δ for all i ∈ {1, 2, 3}.This means, for all i ∈ {1, 2, 3}, that δ ≤ diam(R i ) ≤ δ − π(R i ), which is only possible if diam(R i ) = δ and π(R i ) = 0.In other words, the diameters of R 1 , R 2 and R 3 are equal to the even number δ.Hence, rad(R and we are done, again.So, finally, assume that dist Let w be the last vertex on the z 1 , z 2 -path in R that is closest to z 3 and let δ i be the distances between z i and w for all i ∈ {1, 2, 3}.Then, for all 1 ≤ i < j ≤ 3, it must be Solving the system of the three linear equations above yields It remains to prove that the value of k in (T, k) = ρ(G, p) is optimal with respect to leaf roots of G with parity p.For the connected case, this can be seen as follows.By Corollary 4, 2k ′ − 2 ≥ diam(R) holds for every k ′ -leaf roots R of G.This and Property (T3) of T leads to Finally, let G be a disconnected graph with s ≥ 0 non-trivial connected components G 1 , . . ., G s and t ≥ 0 isolated vertices v 1 , . . ., v t such that s + t ≥ 2. By Proposition 8, (T, k) = ρ(G, k) results from finding (T 1 , k 1 ) = ρ(G 1 , p), . . ., (T s , k s ) = ρ(G s , p) in Step (iii.1.)and assembling them to a k-leaf root T for G with k = max{k 1 , . . ., k s , p + 2} in the Steps (iii.2.) and (iii.3.).After handling the connected case above, we know that T i is an optimal k i -leaf root of G i with parity p for all i ∈ {1, . . ., s}.
Clearly, if s = 0 then a (p + 2)-leaf root is the best possible for parity p, and we are done.Otherwise, assume, without loss of generality, that k = k 1 .Moreover, let R be a p-parity k ′ -leaf root of G and, for all i ∈ {1, . . ., s}, let R i be the smallest subtree of R with leaf set With the four propositions above, Theorem 5 has been proven.□ Lemma 6 Let T be a compressed tree with n leaves and with explicitly given min-max center z, center Z, diameter diam(T ), and leaf-distance d min T .For all integers δ ≥ 0, the compressed tree T ′ = η(T, δ) with min-max center z ′ , center Z ′ , diameter diam(T ′ ), and leaf distance d min T ′ can be computed in O(n) time.
Proof: By definition, T ′ is obtained from T by replacing all n pendant edges with new paths of length δ + 1, each.In the compressed encoding, this takes just n modifications of the weights of edges.More precisely, if v(ℓ)x is a pendent edge of T representing a path of length ℓ that ends at leaf x (where we simply take ℓ = 1 for an unweighted edge) then T ′ has the same pendent edge v(ℓ ′ )x with the new weight ℓ ′ = ℓ + δ.The n constant-time modifications take O(n) time, altogether.
According to Lemma 4, + δ, which takes just constant time to compute.□ Lemma 7 Let s ≥ 0 be an integer and, for all i ∈ {1, . . ., s}, let T i be a given, compressed tree with explicitly given min-max center z i , center Z i , diameter diam(T i ), and leaf-distance d min Ti .For all integers k ≥ 2 and vertices v 1 , . . ., v t , the merged compressed tree T ′ = µ(k, T 1 , . . ., T s , v 1 , . . ., v t ) with center Z ′ and diameter diam(T ′ ) can be computed in O(s + t) time.
Proof: According to definition, the computation of T ′ by µ starts with finding the critical index m, which is the smallest number in {1, . . ., s} with d min Tm = min{d min Ti | 1 ≤ i ≤ s}.Since d min Ti is explicitly known for all given trees, m is found after iterating the input once in O(s) time.
Then, every tree T i , 1 ≤ i ≤ s is attached at z i to a new vertex c by a path of at most

Ti
edges and every vertex v j , 1 ≤ j ≤ t is attached to c with a path of length Each of these paths is compressed into one edge of the respective weight and, hence, this takes O(s + t) time.
It remains to show that Z ′ and diam(T ′ ) can be computed alongside T ′ without consuming essentially more computing time.Both parameters require the identification of a diametral path in T ′ .We recall that every diametral path P connects two leaves of the tree T ′ and, therefore, is either entirely included in one of the trees T 1 , . . ., T s or contains c and connects leaves that stem from different input trees or vertices v 1 , . . ., v t .To be able to cover the first case, we search a tree T a with diam(T a ) = max{diam(T i ) | 1 ≤ i ≤ s}.This works in O(s) time since the diameters are given.If, at the end, P turns out to be part of T a then Z ′ = Z a and diam(T ′ ) = diam(T a ), which is computed in O(1) time.
For the other possibility, we firstly think of the case where P connects two leaves v i and v j , 1 ≤ i < j ≤ t.Then, obviously, diam(T ′ ) = k − π(k) + 2 ≥ diam(T a ) and Z ′ = {c}, which can be decided and computed in O(1) time.
Secondly, one or both end vertices of P may be leaves of the trees T 1 , . . ., T s .To efficiently find P under this condition, we hook additional computations into the iteration of these trees during the evaluation of the µ-operation.More precisely, while a tree T i is attached to c by a path of length p i (that is, p i = k+π(k)

Ti
for i = m and, otherwise, Ti ), we memorize the T ′ -distance between c and a farthest leaf of T i .As diam(T i ) is known in advance for all i ∈ {1, . . ., s}, this JGAA, 28(1) 243-274 (2024) 267 takes just O(1) additional time per iteration and, thus, O(s) time in total.We also define otherwise, the T ′ -distance between c and any present leaf v 1 , . . ., v t .Observe for later that, if t > 0 then hence, d i > d 0 for all i ∈ {1, . . ., s}.
After the evaluation of µ and the associated completion of T ′ , we determine values i 1 and i 2 such that .
To conclude the proof, we show that Z ′ is situated on the recently inserted weighted edge c(p i1 )z i1 , or more precisely, p i1 ≥ δ 1 ≥ δ 2 ≥ 0. That δ 2 ≥ 0 holds since, otherwise, d i1 < d i2 .Similarly, we note that, if one of the end vertices of P is a leaf of v 1 , . . ., v t then i 2 = 0 since, otherwise, d 0 = d i1 < d i2 .So, i 1 is in {1, . . ., s}, and we further observe that 2rad because T a has the largest diameter among the given s trees.This means that rad(T i1 ) ≤ p i1 + d i2 .Using this for the estimation of δ 1 , we get this case, then the edge c(p i1 )z i1 is split into the weighted edge c(p i1 − 1)z ′ 2 and the edge z ′ 2 z ′ 1 .Otherwise, if also π(T ′ ) = 0, then the center z ′ 1 = z ′ 2 is inserted by splitting the edge c(p i1 )z i1 into the weighted edges c(δ 1 )z ′ 1 and z ′ 1 (p i1 − δ 1 )z i1 .In the final case, c(p i1 )z i1 is replaced by inserting the center edge z ′ 1 z ′ 2 between c(δ 2 )z ′ 2 and z ′ 1 (p i1 − δ 1 )z i1 .Altogether, this implies that Z ′ and diam(T ′ ) are always found in O(s) time. □ Knowing the computational complexities of η and µ, we can design an efficient implementation of the main procedure in Algorithm 1.We decided to implement the recursive definition of ρ(G, p) as an iterative traversal of the cotree T of G.The primary reason for this is that the recursive partition of G is almost trivial using T .For instance, connected and disconnected graphs G can easily be distinguished with the cotree.The former have a root labelled by 1 and the latter by 0 .Likewise, we can detect small input graphs, stars, with T by checking if the root is labelled with 1 and if the only child that is labelled with 0 has just leaf-children.For that reason, the main loop of Algorithm 1 is basically divided into three parts, the first two for connected subgraphs of G and the third one for disconnected input.We like to point out, however, that the third part is executed at most once in the first loop-iteration, if G is disconnected.All recursively generated subgraphs of G are connected and, thus, processed by the first or second part.
Recall that, for connected graphs G of sufficient size, the ρ-operation divides G at the unique universal vertex u, to recurse into the non-trivial connected components G 1 , . . ., G s of G − u, and to conquer by merging the according leaf roots T 1 , . . ., T s into a parity-optimal solution for G.This divide and conquer procedure is translated into a traversal of the cotree T as follows.Since input consists of ccgs without true twins, we rely on Proposition 2. That means that nodes with the label 1 , like the root X of T , always have exactly one leaf-child, say u, and one child with label 0 , say Y .The leaf u marks the unique universal vertex in G and Y has children Z 1 , . . ., Z s with label 1 and leaf-children v 1 , . . .v t that represent the non-trivial connected components G 1 , . . ., G s and the isolated vertices v 1 , . . ., v t of G − u.The chosen post-order traversal of T makes sure that, before processing X (and Y ), the nodes Z 1 , . . ., Z s have been visited and finished.Because we use a stack to pass interim results upwards, we always find leaf roots T 1 , . . ., T s for G 1 , . . ., G s on the stack (in reverse order), when we need to compute a leaf root T for the subgraph that corresponds to T X .
We present the details of our construction in Algorithm 1: OptimalLeafRoot.The following theorem summarizes our results.
Theorem 10 Given a chordal cograph G on n vertices and m edges and p ∈ {0, 1}, a compressed κ-leaf root of G with minimum integer κ of parity p can be computed in O(n + m) time.
Proof: Let G be a ccg and p ∈ {0, 1} a parity.We can assume that G is free of true twins as, otherwise, we can remove x for every pair x, y of true twins in G in linear time and, when (T, k) has been computed, insert every x pendant to the parent of the corresponding twin leaf y into T .The cotree T of G is computed in Line 1, which works in linear time O(n + m) as discussed in Section 2.
According to Lemma 6, there is a constant c 1 such that η(T, δ) takes at most c 1 • n computation steps for input trees T with n leaves.In the same way, c 2 is a constant such that µ(k, T 1 , . . ., T s , v 1 , . . ., v t ) requires not more than c 2 (s + t) steps as promised by Lemma 7.
We assume the existence of a constant c 3 that can be used as an upper bound on the number of steps that the algorithm requires for any of the following operational blocks: Firstly, the base case in Line 7 is, in fact, solved by a loop that adds t + 1 leaves to the leaf root T .Here c 3 is supposed to be an upper bound on the costs for one loop iteration.The computation of Line 7 as a whole then requires at most (t + 1) • c 3 steps.Secondly, the Lines 2 and 22 contain for-loops where c 3 shall be a bound on the number of steps needed to go from one iteration to the next.This includes, for instance, traversing the tree T to visit the next node X and to push a pointer to (T i , k i ) onto the stack S. Thirdly, certain lines like Line 10 and Line 13 describe single iterated operations.Beyond the costs of advancing the loop here, c 3 is supposed to additionally bound the computational expenses for one entire iteration.In Line 10, for example, this means the cost of popping from the stack and, in Line 13 the necessary steps to update a maximum are included.Finally, c 3 is also meant to cover the costs for decomposing the cotree like in Line 4, checking certain conditions as in Line 15 and for simple arithmetic computations like for the value of k    We begin the proof with connected input graphs.The idea is to use induction on the height h of the cotree T to show that, then, there is a constant c such that Algorithm 1 requires c(n + m) computation steps to put (T, k) = ρ(G, p) on top of the stack S before finishing the last visited node of T by the post-order-loop in Lines 2 to 27.More precisely, we choose c = c 1 + c 2 + 9c 3 .This would mean that the computation in this case takes O(n + m) steps.
In any case, Algorithm 1 starts with decomposing the cotree below node X by enumerating the s + t children of X in (s + t) • c 3 time.Next, checking if s = 0 in c 3 time allows deciding between the base case, which we handle with the induction start, and the general condition, which we prove with the induction step.
Since G is connected and free of true twins, the induction start is at h = 2 where, according to Section 2.1, the cotree has a 1 -root X with leaf child u and a 0 -child that has the leaf-children v 1 , . . ., v t , only.Then G is the star with center u and leaves v 1 , . . ., v t , that is, n = t + 1 and m = t.This means, Algorithm 1 iterates just one 1 -node (the root X), heads directly into Line 7, and, accordingly, handles this case like Case i. of the ρ-operation.We argue above that this takes (t + 2) • c 3 time for composing the leaf root and for advancing the loop.Afterwards, it pushes (T, k) = ρ(G, p) on top of the stack S in c 3 time before the for-loop finishes X, the last visited node of T .Since s = 0, t = n − 1, and c > 3c 3 , the (4 − p)-leaf root T is constructed in time In the induction step, the height h of T is at least 3 and G is not a star.After decomposing the cotree and checking the condition s > 0, the algorithm enters Line 10 because G is again connected and, thus, the cotree T has a 1 -root X.According to Section 2.1, the root has a leaf-child u and a 0 -child Y with, in turn, 1 -children Z 1 , . . ., Z s , s ≥ 1. Due to post-order traversal, the algorithm consecutively iterates through the subtrees T Z1 , . . ., T Zs in that order before entering Y and then X.As the cotrees T Z1 , . . ., T Zs have height less than h, they fulfill the induction hypothesis.This means for all i ∈ {1, . . ., s} that the algorithm requires not more than c(n i + m i ) + c 3 steps to output (T i , k i ) = ρ(G i , p) on top of the stack S, where G i is the connected component of G − u that corresponds to T Zi with n i = |V (G i )| vertices and m i = |V (G i )| edges.As the isolated vertices v 1 , . . ., v t and the universal vertex u with its n − 1 adjacent edges are not included in G 1 , . . ., G s and as, thus, n 1 + • • • + n s = n − t − 1 and m 1 + • • • + m s = m − n + 1, it takes c((n − t − 1) + (m − n + 1)) + s • c 3 = c • (m − t) + s • c 3 steps to put the entire sequence (T 1 , k 1 ), . . ., (T s , k s ) on top of the stack S. Algorithm 1 pops this list of interim results from the stack in reverse order in Line 10.Although unmentioned for clarity in the listing of Algorithm 1, every tree T i , 1 ≤ i ≤ s is retrieved together with the explicit information on center, min-max center, diameter, and leaf distance.
After that, it is easy to check that k is computed exactly like in Case ii. in the listing of the ρ-operation in Section 3.With the up to three max-oparations, three conditionals, and four arithmetic computations, this is done in at most (3s + 7) • c 3 steps.
Since This completes the induction.
For a disconnected graph G, we also show that the loop in Lines 2 to 27 puts (T, k) = ρ(G, p) on top of the stack S. The cotree T of G has a 0 -root X, which has 1 -children Z 1 , . . ., Z s , s ≥ 0 and leaf-children v 1 , . . ., v t such that s + t ≥ 2. Notice that X, as the root of T , has no parent.Then, as argued before, the post-order traversal consecutively iterates through T Z1 , . . ., T Zs before entering the node X in Line 29.Since the graphs G 1 , . . ., G s are connected, we have seen above that iterating the children of X takes at most c(n 1 +m 1 )+• • •+c(n s +m s ) time, where n i = |V (G i )| and m i = |E(G i )|.This time, n − t = n 1 + • • • + n s and m − t = m 1 + • • • + m s and, thus, at most c(n + m) time is required to put the sequence (T 1 , k 1 ) = ρ(G 1 , p), . . ., (T s , k s ) = ρ(G s , p) on top of the stack S. Again unmentioned, every tree T i , 1 ≤ i ≤ s comes with explicitly designated minmax center, center, diameter and leaf distance.Altogether, it, thus, takes linear time to prepare the interim results.Like in Case iii. of the ρ-operation, the value of k is the maximum among {k 1 , . . ., k s , p + 2}.So, by Lemmas 6 and 7, (T, k) = ρ(G, p) is correctly computed in Lines 32 and 33.Then Line 34 puts (T, k) on top of S, which finishes X, the last visited node of T .With a similar argument as for the connected case above, we see that this is all done in linear time.
Thus, the algorithm takes O(n + m) time in each of the above cases to finally reach Line 37, where (T, k) = ρ(G, p) waits accessible at the top of S. Hence, because G is a ccg without true twins, Theorem 5 tells us that Algorithm 1 provides an optimal k-leaf root T of G with π(k) = p at this point.This proves Theorem 10. □ Observe that Theorem 10 restates our main result from Theorem 1 in a slightly generalized form.By running Algorithm 1: OptimalLeafRoot once for every parity p ∈ {0, 1}, we clearly find an optimal leaf root of the input graph G in linear time.Hence, the proof of Theorem 10 settles Theorem 1, too.

Conclusion
With Theorem 10, we have shown that the OLR problem is linear-time solvable for chordal cographs.Our work also provides a linear-time solution for the k-leaf power recognition problem on chordal cographs.Specifically, for a given ccg G and an integer k, it is sufficient to compute (T, κ) = ρ(G, π(k)) (in linear time with Algorithm 1) to see by κ ≤ k if G is a k-leaf power.We conclude the paper by exploring the differences in the construction of odd and even leaf-roots.As we have seen, merging three or more even leaf roots sometimes requires a slightly stronger increase in k than for odd leaf roots.This can accumulate to an arbitrary big gap between k and k ′ of an optimal odd k-leaf root and an optimal even k ′ -leaf root of a given ccg.For example, Now get back to the leaf root construction for F i .If p = 1 then our procedure handles the only case with s ≥ 2. We get (T i , k i ) = ρ(F i , 1) with This means that, although odd and even leaf root construction follows the same approach, there are k-leaf powers of odd k among the chordal cographs that have optimal even k ′ -leaf roots with k ′ roughly 1.25k.

Figure 1 :
Figure 1: A graph G (left), a 5-leaf root T of G (middle), a 4-leaf root T ′ of G (right).

1 . 2 + 1 4 .
Create a new vertex c. 2. If s > 0 then connect c and the center z m of the critical root by a path of length k+π(k) 2 −d min Tm .If π(k) = 0 and d min Tm = 1 2 k then this means to identify the vertices c and z m .3. For all i ∈ {1, . . ., m − 1, m + 1, . . ., s}, connect c and z i by a path of length k−π(k) − d min Ti .For all j ∈ {1, . . ., t}, connect c and v j by a path of length k−π(k) 2 + 1.
which settles this case, too.Finally, let p = 0 and t ≥ 3, where Step (i.3.)constructs T from η(G, 2) by attaching a new leaf to u.Similar to the odd case, T is obviously a 4-leaf root of G with rad(T ) = 3 = k − 1 < n, diam(T ) = 6 and, thus, π(T ) = 0 and d min T = 1 = 1 + π(T ).To see (T3), suppose to the contrary that Moreover, T has Property (T2) d min T = 1 + π(T ).If π(T ) = 0 then the center of T is a single vertex z, which is also the min-max center.Since z is adjacent to the leaf u, we get d min T = 1.Otherwise, if π(T ) = 1 then T has two center vertices z 1 and z 2 where, without loss of generality, u is attached to z 1 .That makes z 2 the min-max center with distance d min T = 2 to leaf u.This concludes the proof of Proposition 7. □ With the following proposition, we summarize what we have so far and also cover the disconnected case.Proposition 8 Let G be a ccg on n vertices and without true twins and let p ∈ {0, 1} be a given parity.Then (T, k) = ρ(G, p) provides a k-leaf root T of G with π(k) = p and k ≤ n + 1.If G is connected then (T, k) satisfies (T1) and (T2).

Algorithm 1 :
OptimalLeafRootInput: A ccg G = (V, E) without true twins and a parity p ∈ {0, 1} Output: A pair (T, k) of a k-leaf root T of G with smallest p-parity integer k.

= 2 .
T 1 , . . ., T s have n − t − 1 leaves, altogether, Line 22 computes in c 1 (n − t − 1) + s • c 3 time the same extended k-leaf roots T ′ 1 , . . ., T ′ s as ρ.Notice that the subroutine η includes min-max center z ′ i , center Z ′ i , diameter diam(T ′ i ), and leaf distance d min T ′ i for every tree T ′ i , 1 ≤ i ≤ s.Based on that, the Lines 23 and 24 produce with c 2 (s + t) + c 3 steps the same merged k-leaf root T as ρ does.The subroutine µ explicitly returns only the center Z = {z 1 , z 2 } and the diameter diam(T ) with T .However, the min-max center z and the leaf distance d min T are immediately determined in JGAA, 28(1) 243-274 (2024) 271 Line 24 due to attaching u.If π(T ) = 0 then z = z 1 = z 2 and d min T = 1 and, otherwise, z is the center that is not chosen as the parent of u and d min T The costs for these computations are bounded by c 3 .After all that, the result (T, k) = ρ(G, p), including z, Z, diam(T ), and d min T , is pushed onto S in Line 25.This finishes the processing of X, the last visited node of T .Since n ≥ s + t and n ≥ 3 and c = c 1 + c 2 + 9c 3 , the total computation time is((s + t) • c 3 ) + c 3 + (c(m − t) + s • c 3 ) + ((3s + 7) • c 3 ) + (c 1 (n − t − 1) + s • c 3 ) + (c 2 (s + t) + c 3 ) = c(m − t) + c 1 (n − t −1) + c 2 (s + t) + c 3 (6s + t + 9) < cm + c 1 n + c 2 n + c 3 (9n) = (c 1 + c 2 + 9c 3 )n + cm = c(n + m).