The classical supertree problem is to state whether or not a set of partial trees are consistent, and if so construct a tree containing them all. Here, we introduce the classical methods for solving this problem, and explore natural generalizations to the supergenetree problem.
Let Γ be a set of n taxa (usually species in case of the supertree problem, and genes in case of the supergenetree problem), Γ_{i, 1 ≤ i ≤k}be a set of possibly overlapping subsets of Γ, and \mathcal{G}=\left\{{G}_{1},\phantom{\rule{2.36043pt}{0ex}}{G}_{2},\phantom{\rule{2.36043pt}{0ex}}\cdots \phantom{\rule{0.3em}{0ex}},\phantom{\rule{2.36043pt}{0ex}}{G}_{k}\right\} be a set of trees where, for each 1 ≤ i ≤ k, G_{
i
} is a tree for Γ_{
i
}. Let tr\left(\mathcal{G}\right) be the set of triplets of \mathcal{G}\phantom{\rule{0.5em}{0ex}} defined as tr\left(\mathcal{G}\right)=\left\{xyz:\exists \phantom{\rule{2.36043pt}{0ex}}1\le i\le k\phantom{\rule{2.36043pt}{0ex}}\mathsf{\text{such}}\phantom{\rule{2.36043pt}{0ex}}\mathsf{\text{that}}\phantom{\rule{2.36043pt}{0ex}}{G}_{i}{}_{\left\{x,\phantom{\rule{2.36043pt}{0ex}}y,\phantom{\rule{2.36043pt}{0ex}}z\right\}}=xyz\right\}. Let \mathcal{T}\left(\Gamma ,\phantom{\rule{2.36043pt}{0ex}}E\right) be the triplet graph with the set of vertices Γ and the set of edges E = {xy : ∃ z ∈ Γ such that xyz\in tr\left(\mathcal{G}\right)} (see Figure 2 for an example).
The classical BUILD algorithm [1] determines, in polynomial time, whether a set of triplets is consistent and if so constructs a tree T, possibly nonbinary, compatible with them. The algorithm takes as input the graph \mathcal{T}=\mathcal{T}\left(\Gamma ,\phantom{\rule{2.36043pt}{0ex}}E\right). Let \mathcal{C}\left(\mathcal{T}\right)=\left\{{C}_{1},\phantom{\rule{2.36043pt}{0ex}}\cdots \phantom{\rule{0.3em}{0ex}},\phantom{\rule{2.36043pt}{0ex}}{C}_{m}\right\} be the set of connected components of \mathcal{T}\phantom{\rule{0.5em}{0ex}}. If \mathcal{T}\phantom{\rule{0.5em}{0ex}} has at least three vertices and \left\mathcal{C}\left(\mathcal{T}\right)\right=1, then \mathcal{G}\phantom{\rule{0.5em}{0ex}} is inconsistent, and the algorithm terminates. For example, the set of five gene trees of Figure 2 is inconsistent, as the corresponding triplet graph (including dotted lines) is connected. Otherwise, if \leftV\left(\mathcal{T}\right)\right\ge 3, a polytomy is created over \mathcal{C}\left(\mathcal{T}\right), the internal node of the polytomy being the root r(T) of the compatible tree T under construction and its children being m subtrees with leafsets V(C_{1}),..., V(C_{
m
}), with their topology yet to be determined (where V(C_{
i
}) ⊆ Γ denotes the set of taxa appearing in C_{
i
}). The algorithm then recurses into each connected component, i.e. the subtree for V(C_{
i
}) is determined recursively from the graph \mathcal{T}\left(V\left({C}_{i}\right),\phantom{\rule{2.36043pt}{0ex}}E{}_{{C}_{i}}\right) defined by E C_{
i
}= {xy : ∃ z ∈ Γ such that xyz\in tr\left(\mathcal{G}{}_{V\phantom{\rule{2.36043pt}{0ex}}\left({C}_{i}\right)}\right)}. If, at any step, the considered graph has a single component containing more than two vertices, then \mathcal{G}\phantom{\rule{0.5em}{0ex}} is reported as an inconsistent set of trees and the algorithm terminates. Otherwise, recursion terminates when the graph has at most two vertices, eventually returning a supertree T. See Figure 3 for an example.
The BUILD algorithm has been generalized in an algorithm called AllTrees [20] to output all supertrees compatible with a set of triplets in case consistency holds. Instead of taking each element of \mathcal{C}\left(\mathcal{T}\right) as a separate leaf of r(T), all possible groupings, in other words all partitions of \mathcal{C}\left(\mathcal{T}\right), are considered (see Figure 3, right, for a choice of bipartitions). For each partition \mathcal{P}\left(\mathcal{C}\left(\mathcal{T}\right)\right) of \mathcal{C}\left(\mathcal{T}\right), a polytomy is created over \mathcal{P}\left(\mathcal{C}\left(\mathcal{T}\right)\right). The algorithm then iterates by considering each possible partition of each subgraph induced by each element of \mathcal{P}\left(\mathcal{C}\left(\mathcal{T}\right)\right). The algorithm is polynomial in the size of the output that may be exponential in the size of the input.
A tree T compatible with \mathcal{G}\phantom{\rule{0.5em}{0ex}} such that no internal edge of T can be contracted so that the resulting tree is also compatible with \mathcal{G}\phantom{\rule{0.5em}{0ex}} is called a minimally resolved supertree. Minimally resolved supertrees contain all the information about all supertrees compatible with \mathcal{G}\phantom{\rule{0.5em}{0ex}} but in a "compressed" format. By exhibiting some properties on graph components, Semple shows in [27] how some partitions of the triplet graph components can be avoided without loss of generality. The new developed algorithm, named AllMinTrees [27], outputs a minimally resolved tree in polynomial time. However, it was shown in [15] that the cardinality of the solution space can be exponential in n = Γ, leading to an exponential time algorithm with \Omega \left({\frac{n}{2}}^{\frac{n}{2}}\right).
Notice that, in general, the trees output by all these methods are nonbinary trees.
Extensions to the SuperGeneTree problem
Natural exact solutions for the supertree problem can be extended to the supergenetree problem as follows:

(1)
Use AllMinTrees to output all minimally resolved supertrees, and for each one which is nonbinary in general, find in linear time a resolution minimizing the reconciliation [16, 32] or duplication [31] cost. Among all optimally resolved trees, select one of minimum cost. Clearly this approach has the same complexity as the AllMinTrees algorithm, multiplied by a factor of n to resolve each tree, which is \Omega \left(n\cdot {\frac{n}{2}}^{\frac{n}{2}}\right).

(2)
As we are seeking a binary tree, each created node x of the supergenetree T under construction should determine a bipartition \left(\mathcal{L}\left({T}_{{x}_{l}}\right),\phantom{\rule{2.36043pt}{0ex}}\mathcal{L}\left({T}_{{x}_{r}}\right)\right). Therefore, the AllTrees algorithm can be simplified by considering, instead of all partitions of \mathcal{C}\left(\mathcal{T}\right), only all bipartitions of the triplet graph components set. See an example in Figure 3, right. Notice that this simplification approach is not applicable to the AllMinTrees algorithm, as by imposing bipartitions, the minimum resolution condition cannot be guaranteed.
A branchandbound approach
The tree space which is explored by the two exact methods described above can be reduced by using a branchandbound approach. Consider for example method (1) using the AllMinTrees algorithm. At each iteration of computing one minimally resolved tree, resolve the intermediate nonbinary tree obtained at this step, using for example the lineartime algorithm presented in [16]. If its reconciliation cost is greater than the cost of a full tree already obtained at a previous stage of the AllMinTrees algorithm, then stop expanding this tree as this can only increase the reconciliation cost.
A dynamic programming approach
The recursive topdown method (2) can instead be handled by a dynamic programming approach computing the minimum reconciliation cost of a tree on a subset of Γ according to the reconciliation costs of trees on smaller subsets, similarly to the wrok done in [13].
More precisely, let P be an arbitrary subset of Γ, and denote by R(P) the minimum duplication cost of a tree T_{
P
} having leafset P and compatible with the set \mathcal{G}{}_{P}=\left\{{G}_{1}{}_{P},\phantom{\rule{2.36043pt}{0ex}}{G}_{2}{}_{P},\phantom{\rule{2.36043pt}{0ex}}\cdots \phantom{\rule{0.3em}{0ex}},\phantom{\rule{2.36043pt}{0ex}}{G}_{k}{}_{P}\right\}. Let \mathcal{T}\left(P,\phantom{\rule{2.36043pt}{0ex}}E{}_{P}\right) be the BUILD graph restricted to P and \mathcal{G}{}_{P}, and C\left(\mathcal{T}\right)=\left\{{C}_{1},\phantom{\rule{2.36043pt}{0ex}}\cdots \phantom{\rule{0.3em}{0ex}},\phantom{\rule{2.36043pt}{0ex}}{C}_{m}\right\} the set of its connected components. If C\subseteq \mathcal{C}\left(\mathcal{T}\right), by V(C) we mean {\cup}_{{C}_{i}\in C}V\left({C}_{i}\right). Denote the complement of C by \stackrel{\u0304}{C}=\mathcal{C}\left(\mathcal{T}\right)\backslash C. Finally set d\left(V\left(C\right),\phantom{\rule{2.36043pt}{0ex}}V\left(\stackrel{\u0304}{C}\right)\right) to 0 if s(V(C)) and s\left(V\right(\stackrel{\u0304}{C})) are separated in S, in which case (V(C), V\left(\stackrel{\u0304}{C}\right) is the bipartition of a speciation node, and 1 otherwise i.e. if (V(C), V\left(\stackrel{\u0304}{C}\right) is the bipartition of a duplication node. Then:
R\left(P\right)=\underset{C\subset \mathcal{C}\left(\mathcal{T}\right)}{\mathsf{\text{min}}}R\left(V\left(C\right)\right)+R\left(V\left(\stackrel{\u0304}{C}\right)\right)+d\left(V\left(C\right),\phantom{\rule{2.36043pt}{0ex}}V\left(\stackrel{\u0304}{C}\right)\right)
the value of interest being R(Γ). First note that, assuming constanttime lca queries over S, d(V(C), V\left(\stackrel{\u0304}{C}\right) can be computed in constant time if s(V(C)) and s\left(V\left(\stackrel{\u0304}{C}\right)\right) can be accessed in constant time, since if suffices to check that the lca of s(V(C)) and s\left(V\left(\stackrel{\u0304}{C}\right)\right) differs from both. To achieve this, we precompute s(X) for every subset X of Γ of size 1, 2,..., n in increasing order. Noting that if X > 1, then for any x ∈ X, s(X) = lca_{
S
}(s(X \ {x}), s(x)), s(X) can be computed in constant time assuming that s(X \ {x}) was computed previously and assuming constanttime lca queries. As there are 2^{n} subsets of Γ, each computed in constant time, this preprocessing step takes time O(2^{n}).
As for R(Γ), we can simply ensure that each R(P) is computed at most once by storing its value in a table for subsequent accesses (i.e. when R(P) is needed, we use its value if it has been computed, or compute it and store it otherwise). In this manner, each subset P takes time, not counting the recursive calls, proportional to \leftP\right\left\mathcal{G}\right+\leftP\right+{2}^{\left\mathcal{C}\left(\mathcal{T}\right)\right} to construct \mathcal{T}\left(P,\phantom{\rule{2.36043pt}{0ex}}E{}_{P}\right), find \mathcal{C}\left(\mathcal{T}\right), and evaluate each bipartition of \mathcal{C}\left(\mathcal{T}\right). We will simply use the fact that \leftP\right\left\mathcal{G}\right+\leftP\right+{2}^{\left\mathcal{C}\left(\mathcal{T}\right)\right} is in O(2^{n}). As this has to be done for, at worst, each of the 2^{n} subsets of Γ, we get a total time O(2^{n} + 2^{n} ·2^{n}) = O(4^{n}). Note that this analysis probably overestimates the actual complexity of the algorithm, as we are assuming that each subset P and each component set \mathcal{C}\left(\mathcal{T}\right) are both always of size n. It is also worth mentioning that the R(P) recurrence can easily adapted to the mutation cost (duplications + losses).
A greedy heuristic for the duplication cost
Instead of trying all partitions of the triplet graph components set at each step of the AllTrees or AllMinTrees algorithms, if the goal is to minimize the duplication cost, then a natural greedy approach would be to choose the best partition at each iteration, namely the one allowing to minimize the number of duplications preceding each speciation event. Such an approach would result in pushing duplications down the tree. It leads to the following restricted version of the supergenetree problem.
MINIMUM PRESPECIATION DUPLICATION PROBLEM (MINPRESPEDUP PROBLEM):
Input: A species set Σ and a binary species tree S for Σ; a gene family Γ, a set Γ_{i,1≤i≤k}of subsets of Γ, and a set \mathcal{G}=\left\{{G}_{1},\phantom{\rule{2.36043pt}{0ex}}{G}_{2},\phantom{\rule{2.36043pt}{0ex}}\cdots \phantom{\rule{0.3em}{0ex}},\phantom{\rule{2.36043pt}{0ex}}{G}_{k}\right\} of consistent gene trees where, for each 1 ≤ i ≤ k, G_{
i
} is a tree on Γ_{
i
}.
Output: Among all gene trees for Γ compatible with \mathcal{G}\phantom{\rule{0.5em}{0ex}}, one tree T with minimum prespeciation duplication nodes.
We will show in the following section that even this restricted version of the supergenetree problem is hard. Here, we give the intuition of a natural way of solving this problem, that reduces to repeated applications of the MaxCut problem. Although known to be NPhard, efficient heuristics exist (up to a factor of 0.878 [12]), that can be used for our purpose.
For the supertree problem, the triplet graph \mathcal{T}=\mathcal{T}\left(\Gamma ,\phantom{\rule{2.36043pt}{0ex}}E\right) represents all triplets of the input trees that have to be combined. In the case of the supergenetree problem, another tree is available, the species tree S. A triplet xyz found in the input trees \mathcal{G}\phantom{\rule{0.5em}{0ex}} can be reconciled with S, and if r(xyz) is a duplication, then any tree compatible with G must contain this duplication. Say that r(xyz) is a required duplication mapped to r(S) if s(r(xyz)) = r(S) and r(xyz) is a duplication. Let us include this information in \mathcal{T}\phantom{\rule{0.5em}{0ex}}. More precisely, let \mathcal{C}=\mathcal{C}\left(\mathcal{T}\right) denote the set of connected components of \mathcal{T}\phantom{\rule{0.5em}{0ex}}, and let \mathcal{T}\left(\mathcal{C}\right) be the graph whose vertex set is \mathcal{C}\phantom{\rule{0.5em}{0ex}}, and {C}_{1},\phantom{\rule{2.36043pt}{0ex}}{C}_{2}\in \mathcal{C} share an edge if C_{1} has vertices x, y and C_{2} has a vertex z such that xyz is a triplet in \mathcal{G}\phantom{\rule{0.5em}{0ex}} with r(xyz) being a required duplication mapped to r(S). If there are, say, d distinct such triplets, one can possibly set a weight of d to the C_{1}C_{2} edge. See Figure 4 for an example.
Consider the problem of clustering the components of \mathcal{T}\left(\mathcal{C}\right) into two parts B_{1}, B_{2} of a bipartition in a way minimizing the number of duplications preceding the speciation event r(S). For each C_{1} ∈ B_{1} and C_{2} ∈ B_{2} such that C_{1}C_{2} is an edge of \mathcal{T}\left(\mathcal{C}\right), a tree T rooted at the bipartition (B_{1}, B_{2}) contains the required duplications mapped to r(S) represented by the C_{1}C_{2} edge. If there are k such edges between B_{1} and B_{2} totalizing a weight of w, the single duplication at the root of T contains those w required duplications. In other words, we have "merged" w required duplications into one. It then becomes natural to find the bipartition of \mathcal{T}\left(\mathcal{C}\right) that merges a maximum of duplications, i.e. that contains a set of edges crossing between the two parts of maximum weight. This is the wellknown MaxCut problem. For instance in Figure 4, the MaxCut has a weight of 3 and leads to the optimal tree T_{1}. Any other bipartition sends a required duplication to a lower level and is hence suboptimal. The T_{2} tree is obtained from first taking the suboptimal ({a_{1}, b_{1}, d_{1}}, {c_{1}, e_{1}, f_{1}}) bipartition, which creates a duplication at the root and defers the c_{1}e_{1}f_{1} required duplication for later.
Note however that the components of \mathcal{T}\phantom{\rule{0.5em}{0ex}} may contain required duplications themselves, which are not represented by the edges of \mathcal{T}\left(\mathcal{C}\right). Thus, a MaxCut must then be applied recursively on both parts of the chosen bipartition. Therefore, this method does not benefit directly from the efficient approximation factor known for the MaxCut problem, as the approximation error stacks with each application. In the next section, we show that, unlike MaxCut, the MinPreSpeDup problem cannot admit a constant factor approximation (unless P = NP).