{'fraction_non_alphanumeric': 0.0689498752551599, 'fraction_numerical': 0.008996749073864066, 'mean_word_length': 3.345597897503285, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 2, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Graph Triangulations and the Compatibility of Unrooted Phylogenetic Trees

We characterize the compatibility of a collection of unrooted phylogenetic trees as a question of determining whether a graph derived from these trees --- the display graph --- has a specific kind of triangulation, which we call legal. Our result is a counterpart to the well known triangulation-based characterization of the compatibility of undirected multi-state characters.


INTRODUCTION
A phylogenetic tree or phylogeny is an unrooted tree T whose leaves are in one-toone correspondence with a set of labels (taxa) L(T ). If L(T ) = X, we say that T is a phylogenetic tree for X, or a phylogenetic X-tree [8]. A phylogenetic tree represents the evolutionary history of a set of species, which are the labels of the tree.
Suppose T is a phylogenetic tree. Given a subset Y ⊆ L(T ), the subtree of T induced by Y , denoted T |Y , is the tree obtained by forming the minimal subgraph of T connecting the leaves with labels in Y and then suppressing vertices of degree two. Let T ′ be some other phylogenetic tree such that L(T ′ ) ⊆ L(T ). We say that T displays T ′ if T ′ can be obtained by contracting edges in the subtree of T induced by L(T ′ ).
A profile is a tuple P = (T 1 , T 2 , . . . , T k ), where each T i is a phylogenetic tree for some set of labels L(T i ). The T i s are called input trees, and we may have L(T i ) ∩ L(T j ) = ∅ for i = j. A supertree for P is a phylogeny T with L(T ) = k i=1 L(T i ). Profile P is compatible if there exists a supertree T for P that displays T i , for each i ∈ {1, . . . , k}. The phylogenetic tree compatibility problem asks, given a profile P, whether or not P is compatible. This question arises when trying to assemble a collection of phylogenies for different sets of species into a single phylogeny (a supertree) for all the species [4]. The phylogenetic tree compatibility problem asks whether or not it is possible to do so via a supertree that does not conflict with any input tree.
Phylogenetic tree compatibility is NP-complete [9] (but the problem is polynomiallysolvable for rooted trees [1]). Nevertheless, Bryant and Lagergren have shown that the problem is fixed-parameter tractable for fixed k [2]. Their argument relies on a partial characterization of compatibility in terms of tree-decompositions and tree-width of a structure that they call the "display graph" of a profile (this graph is defined in Section 3). Here we build on their argument to produce a complete characterization of compatibility in terms of the existence of a special kind of triangulation of the display graph. These legal triangulations (defined in Section 3) only allow certain kinds of edges to be added. Our result is a counterpart to the well-known characterization of character compatibility in terms of triangulations of a class of intersection graphs [3], which has algorithmic consequences [5,7]. Our characterization of tree compatibility may have analogous implications.

PRELIMINARIES
Let G be a graph. We write V (G) and E(G) to denote the vertex set and edge set of G, respectively. Suppose C is a cycle in G. A chord in C is any edge of G whose endpoints are two nodes that are not adjacent in C. G is said to be chordal if and only if it every cycle of length at least four has a chord. A graph G ′ is a chordal fill-in or triangulation of is called a fill-in for G and the edges in it are called fill-in edges.
A tree decomposition for a graph G is a pair (T, B), where T is a tree and B is a mapping from V (T ) to subsets of V (G) that satisfies the following three properties.
forms a subtree of T . It is well known that if G is chordal, G has a tree-decomposition (T, B) where (i) there is a one-to-one mapping C from the vertices of T to the maximal cliques of G and (ii) for each vertex x in T , B(x) consists precisely of the vertices in the clique C(x) [6]. This sort of tree decomposition is called a clique tree for G. Conversely, let (T, B) be a tree decomposition of a graph G and let F be the set of all {u, v} / ∈ E(G) such that {u, v} ⊆ B(x) for some x ∈ V (T ). Then, F is a chordal fill-in for G [6]. We shall refer to this set F as the chordal fill-in of G associated with tree-decomposition (T, B) and to the graph G ′ obtained by adding the edges of F to G as the triangulation of G associated with (T, B).

LEGAL TRIANGULATIONS AND COMPATIBILITY
The display graph of a profile P = (T 1 , . . . , T k ) is the graph G = G(P) formed from the disjoint graph union of T 1 , . . . , T k by identifying the leaves with common labels (see Fig. 1 of [2]). An edge e of G is internal if, in the input tree where it originated, both endpoints of e were internal vertices; otherwise, e is non internal. A vertex v of G is called a leaf if it was obtained by identifying input tree leaf nodes with the same label ℓ. The label of v is ℓ. A non-leaf vertex of G is said to be internal.
A triangulation G ′ of the display graph G is legal if it satisfies the following conditions. (LT1) Suppose a clique in G ′ contains an internal edge. Then, this clique can contain no other edge from G (internal or non internal). (LT2) Fill-in edges can only have internal vertices as their endpoints.
Note that the above conditions rule out a chord between vertices of the same tree. Also, in any legal triangulation of G, any clique that contains a non internal edge cannot contain an internal edge from any tree.
The importance of legal triangulations derives from the next results, which are proved in the next section.

PROOFS
The proofs of Lemmas 1 and 2 rely on a new concept. Suppose T 1 and T 2 are phylogenetic trees such that L(T 2 ) ⊆ L(T 1 ). An embedding function from T 1 to T 2 is a surjective map φ from a subgraph of T 1 to T 2 satisfying the following properties. (EF1) φ maps labeled vertices to vertices with the same label.  Proof. The "only if" part was already observed by Bryant and Lagergren (see Lemma 1 of [2]). We now prove the other direction.
To prove that T 1 displays T 2 , we argue that T 2 can be obtained from T 1 |L(T 2 ) by a series of edge contractions, which are determined by the embedding function φ from T 1 to T 2 . Let T ′ 1 be the graph obtained from T 1 |L(T 2 ) by considering each vertex v of T 2 and identifying all vertices of φ −1 (v) in T 1 |L(T 2 ) to obtain a single vertex u ′ with φ(u ′ ) = v. By property (EF2), each such step yields a tree. By properties (EF1)-(EF3), each vertex v of T 1 |L(T 2 ) is in the domain of φ. Thus, function φ is now a bijection between T 2 and T ′ 1 that satisfies (EF1)-(EF3).
We claim that for any two vertices u, v ∈ V (T 2 ), there is an edge {u, v} ∈ E(T 2 ) if and only if there is an edge The "only if" part follows from property (EF3). For the other direction, assume by way of contradiction that {x, y} / ∈ E(T 2 ), but that {φ −1 (x), φ −1 (y)} ∈ E(T ′ 1 ). Let P be the path between vertices x and y in T 2 . By property (EF3), there is a path between nodes φ −1 (x), φ −1 (y) in tree T ′ 1 that does not include the edge {φ −1 (x), φ −1 (y)}. This path along with the edge {φ −1 (x), φ −1 (y)} forms a cycle in T ′ 1 , which gives the desired contradiction. Thus, the bijection φ between T 2 and T ′ 1 is actually an isomorphism between the two trees. It now follows from property (EF1) that T 1 displays T 2 .
The preceding lemma immediately implies the following characterization of compatibility. Proof of Lemma 1. If P is compatible, there exists a supertree for P that displays T i for i = 1, . . . , k. Let T be any such supertree. By Lemma 4, for i = 1, . . . , k, there exists an embedding function φ i from T to T i . We will use T and the φ i s to build a tree decomposition (T G , B) corresponding to a legal triangulation G ′ of the display graph G of P. The construction closely follows that given by Bryant and Lagergren in their proof of Theorem 1 of [2]; thus, we only summarize the main ideas.
Initially we set T G = T and, for every v ∈ V (T ), B(v) = {φ i (v) : v in the domain of φ i ; 1 ≤ i ≤ k}. Now, (T G , B) satisfies the vertex coverage property and the coherence property, but not edge coverage [2]. To obtain a pair (T G , B) that satisfies all three properties, subdivide the edges of T G and extend B to the new vertices. Do the following for each edge {x, y} of T G . Let F = {{u 1 , v 1 }, . . . , {u m , v m }} be set of edges of G such that u i ∈ B(x) and v i ∈ B(y). Observe that F contains at most one edge from T i , for i = 1, . . . , k (thus, m ≤ k) . Replace edge {x, y} by a path x, z 1 , . . . , z m , y, where z 1 , . . . , z m are new vertices. For i = 1, 2, . . . , m, let B(z i ) = (B(x) ∩ B(y)) ∪ {v 1 , . . . , v i , u i , . . . , u m }. The resulting pair (T G , B) can be shown to be a tree decomposition of G of width k (see [2]).
The preceding construction guarantees that (T G , B) satisfies two additional properties: Next, we prove Lemma 2. For this, we need some definitions and auxiliary results. Assume that the display graph of profile P has a legal triangulation G ′ . Let (T ′ , B) be a clique tree for G ′ . For each vertex v ∈ V (G), let N (v) denote the set of all nodes in the clique tree T ′ that contain v. Observe that the coherence property implies that N (v) induces a subtree of T ′ .

Lemma 5. Suppose vertex v is a leaf in tree
Then, for any j ∈ {1, . . . , k}, at most one internal vertex u from input tree T j is present in U (v). Furthermore, for any such a vertex u we must have that {u, v} ∈ E(G).
Assume by way of contradiction that the claim is false. Then, there exists a j = i and an edge {x, y} ∈ T ′ such that e ⊆ B(x), e ⊆ B(y), and there are vertices a, b ∈ V (T j ), a = b, such that a ∈ B(x) and b ∈ B(y).
Deletion of edge {x, y} partitions V (T ′ ) into two sets X and Y . Let P = {a ∈ V (T j ) : a ∈ B(z) for some z ∈ X} and Q = {b ∈ V (T j ) : b ∈ B(z) for some z ∈ Y }. By the coherence property, (P, Q) is a partition of V (T j ). There must be a vertex p in set P and a vertex q in set Q such that {p, q} ∈ E(T j ). Since G ′ is a legal triangulation, there must be a node z in T ′ such that p, q ∈ B(z). Irrespective of whether z is in set X or Y , the coherence property is violated, a contradiction.
A legal triangulation of the display graph of a profile is concise if (C1) each internal edge is contained in exactly one maximal clique in the triangulation and (C2) every vertex that is a leaf in some tree is contained in exactly one maximal clique of the triangulation.

Lemma 7.
Let G be the display graph of a profile P. If G has a legal triangulation, then G has a concise legal triangulation.
Proof. Let G ′ be a legal triangulation of the display graph G of profile P that is not concise. Let (T ′ , B) be a clique tree for G ′ . We will build a concise legal triangulation for G by repeatedly applying contraction operations on (T ′ , B). The contraction of an edge e = {x, y} in T ′ is the operation that consists of (i) replacing x and y by a single (new) node z, (ii) adding edges from node z to every neighbor of x and y, and (iii) making B(z) = B(x) ∪ B(y). Note that the resulting pair (T ′ , B) is a tree decomposition for G (and G ′ ); however, it is not guaranteed to be a clique tree for G ′ . We proceed in two steps. First, for every leaf v of G such that |N (v)| > 1, contract each edge e = {x, y} in T ′ such that x, y ∈ N (v). In the second step, we consider each edge e = {u, v} of G such that |N (u) ∩ N (v)| > 1, contract each edge {x, y} in T ′ such that x, y ∈ N (u) ∩ N (v). Lemma 5 (respectively, Lemma 6) ensures that each contraction done in the first (respectively, second) step leaves us with a new tree decomposition whose associated triangulation is legal. Furthermore, the triangulation associated with the final tree decomposition is concise.
Proof of Lemma 2. We will show that, given a legal triangulation G ′ of the display graph G of profile P, we can generate a supertree T for P along with an embedding function φ i from T to T i , for i = 1, . . . , k. By Lemma 4, this immediately implies that P is compatible By Lemma 7, we can assume that G ′ is concise. Let (T ′ , B) be a clique tree for G ′ . Initially, we make T = T ′ . Next, for each node x of T , we consider three possibilities: (ii) Add an edge between node x u and every node neighbor y of x such that u ∈ B(y). (iii) Add an edge between node x v and every neighbor y of x such that v ∈ B(y). (iv) For each neighbor y of x such that u / ∈ B(y) and v / ∈ B(y), add an edge from y to node x u or node x v , but not to both (the choice of which edge to add is arbitrary).
(v) Make φ i (x u ) = u and φ i (x v ) = v. By construction (Case 1) and the legality and conciseness of (T ′ , B), for every ℓ ∈ k i=1 L(T i ) there is exactly one leaf x ∈ V (T ) that is labeled ℓ. Thus, T is a supertree of profile P. Legality also ensures that the function φ i is a surjective map from a subgraph of T to T i . Furthermore, the handling of Case 1 guarantees that φ i satisfies (EF1). The coherence of (T ′ , B) and ensures that φ i satisfies (EF2). The handling of Case 2 and conciseness ensure that φ i satisfies (EF3). Thus, φ i is an embedding function, and, by Lemma 4, profile P is compatible.