1 Introduction

Phylogenetic trees are discrete mathematical objects that capture the evolutionary behavior of biological processes; they have been extensively used and studied both as data structures as well as symbolic objects. Phylogenetic trees are able to encode vastly different evolutionary patterns through various branching configurations, which define the tree’s shape or combinatorial type—more formally, the tree’s topology. In this paper, we focus on phylogenetic trees as discrete geometric objects and study the behavior of their topology using tropical geometry. Specifically, we propose the tropical line segment as a framework to study how tree topologies vary. Our main contributions are a detailed study of the occurrence and behavior of tree topologies and a method to compute tropical line segments in tropical geometric phylogenetic tree space. Our study is conducted relative to the current standard for the space of phylogenetic trees, proposed by Billera et al. [10], and referred to as BHV space (after the authors’ initials). BHV space is a moduli space of phylogenetic trees whose geometry is characterized by unique geodesics and whose structure is defined by tree topologies.

We prove a combinatorial theorem that describes all tree topologies that exist along the tropical line segment between any two given trees, as well as a framework for the notion of invariance of tree topologies on a tropical line segment. We also give an algorithm that computes tropical line segments and compare tropical line segments to BHV geodesics. We find that the tropical setting results in a more subtle behavior of trajectories between vastly different tree topologies.

The remainder of our paper is organized as follows. In Sect. 2, we give formalities on phylogenetic trees and tree spaces; we also provide the basics of tropical geometry and discuss the coincidence of tropical geometry and tree space. A review on the literature on comparisons between trees is also given, as well as a detailed overview of BHV space and its geometry. In Sect. 3, we define the tropical line segment and characterize the geometry of phylogenetic tree space in the tropical geometric setting. In Sect. 4, we provide our main results on tree topologies on tropical line segments, which are a combinatorial theorem that provides all tree topologies occurring along a tropical line segment and a notion of invariance of tree topologies on tropical line segments. We also present an algorithm to compute tropical line segments and compare their behavior relative to BHV geodesics in terms of trajectories across tree space and between different tree topologies. We show that the tropical line segment does not cross the origin, which differs from the trajectory of BHV geodesics between trees with vastly different tree topologies. We close with a discussion in Sect. 5.

2 Trees, Tree Spaces, and Tropical Geometry

In this section, we present the basics of tropical geometry, provide background on phylogenetic trees and tree spaces, and discuss the coincidence between tropical geometry and tree spaces. We overview how trees are compared within tree spaces, focusing on the setting of BHV space and its geometry. Finally, we define the tropical line segment and discuss some of its geometric properties.

Notation. In this paper, \(N \in {\mathbb {N}}\). We use the notation \([N] := \{1, 2, \ldots , N\}\) and \(n := \left( {\begin{array}{c}N\\ 2\end{array}}\right) \). Also, we write interchangeably \(w(i,j) = w_{ij} = w_{\{i,j \}}\).

2.1 Tropical Algebra and Tropical Geometry

Tropical algebra is based on the following semiring with linearizing operations given as follows.

Definition 2.1

The tropical (max-plus) semiring is \(({\mathbb {R}}\cup \{ -\infty \}, \boxplus , \odot )\) with addition and multiplication defined by

$$\begin{aligned} a \boxplus b := \max (a,b),\qquad a \odot b := a + b. \end{aligned}$$

Existing literature on tropical geometry specifies a min-plus semiring, where the addition of two elements is given by their minimum and denoted by \(\oplus \), rather than their maximum: \(({\mathbb {R}}\cup \{\infty \}, \oplus , \odot )\) [38]. The min-plus and max-plus semirings are isomorphic. In the context of phylogenetic trees, the max-plus semiring is a more appropriate convention to adopt and consistent with existing literature on tropical geometric methods in tree spaces, e.g., [29, 41, 45].

The tropical operations are commutative and associative, and multiplication distributes over addition. Tropical subtraction is not defined, which gives a semiring rather than a ring. Tropicalization refers to replacing classical arithmetic operations with the tropical versions. Tropical geometry is the study of the geometry of nonlinear loci of polynomial systems defined in the tropical semiring.

2.2 Defining Phylogenetic Trees

Phylogenetic trees are the fundamental mathematical model for biological evolution. They are constructed from molecular sequence data of a finite number of species, and graphically represent the evolutionary phylogeny of the species.

Definition 2.2

A phylogenetic tree \(T=(V,E)\) is an acyclic connected graph with at most one vertex of degree 2. V is a set of vertices that are labeled terminal nodes with degree 1 called leaves; non-leaf vertices have degree greater than 2. E is a set of nonnegative length edges or branches that represent evolutionary time. Edges that connect to leaves are called external or pendant edges; otherwise, they are known as internal edges.

When there is a common ancestor from which all leaves evolve, the tree is called rooted and the root is a unique node of degree 2. In rooted trees, the evolution progresses from the common ancestor (root) by a series of bifurcations (edges, E) and ends in the terminal nodes (leaves, V). When there is no common ancestor among the leaves, the tree is unrooted.

Remark 2.3

In the case of rooted trees, one may also imagine an edge extending from the root to a leaf labeled 0. In this case, the interior vertex connecting to the root (leaf label 0) will have degree 3, however, by convention, rooted trees are not depicted this way, which is why the root in such trees appears to be a node of degree 2.

Methods for reconstructing phylogenetic trees from molecular sequence data are generally either distance-based or statistical. Distance-based methods entail specifying distance matrices between the sequences via a genetic distance—such as Hamming distance—and grouping sequences that are closely related under the same node, with branch lengths representing the observed distances between sequences. For a survey on distance-based tree reconstruction methods, see for example [32].

Statistical reconstruction methods entail specifying some classical statistical criterion, such as likelihood or parsimony, and then optimizing [16, 17]. The criteria are defined on the principle that in DNA evolution, nucleotides are substituted following a continuous-time Markov chain (or, more generally, an independent time-reversible model for finite sites [42]). The motivation for statistical methods for tree reconstruction arises from the uncertainty of the “true" phylogenetic tree, since different choices of molecular sequences (which may be due to choice of gene or coding region) leads to different gene trees [19]. Additionally, there is an extremely high number of possible tree topologies [36]: the number of tree topologies for a rooted, binary tree (i.e., a bifurcating tree with exactly two descendants stemming from each interior node) with N leaves is

$$\begin{aligned} (2N-3)!! = (2N-3) \times (2N-5) \times \cdots \times 3. \end{aligned}$$
(1)

Previous work has shown that solutions to statistical optimization problems are tractable under certain conditions and assumptions. For example, under uniform distributivity, the optimization of parsimony-based objective functions is known to be an NP-complete Steiner tree problem [18]. Various restrictions of the Steiner tree problem (e.g., the minimum spanning tree problem) can be solved in polynomial time [21]. In biological applications where the data and specific problem of study allow certain distributional assumptions (e.g., identifiability of mixture distributions), statistical methods can be easy and computationally efficient to implement [4, 27, 33]. The focus of this paper, however, is on the number of tree topologies (1) and their occurrences within tree spaces.

Definition 2.4

For a phylogenetic tree T with N leaves labeled by [N], and with branch length \(b_e \in {\mathbb {R}}_{\ge 0}\) associated to each edge e in T, its tree metric is the map

$$\begin{aligned} w:[N] \times [N]\rightarrow {\mathbb {R}}_{\ge 0},\qquad w(i,j)\mapsto \bigodot _{e \in P_{\{i,j \}}} b_e, \end{aligned}$$

where \(P_{\{i,j \}}\) is the unique path between leaves i and j.

Tree metrics are metric representations of phylogenetic trees in terms of pairwise distances between leaves. Tree metrics may also be represented as cophenetic vectors [12],

$$\begin{aligned} (w(1,2),w(1,3),\ldots , w(N-1, N)) \in {\mathbb {R}}^n_{\ge 0}, \end{aligned}$$
(2)

where the entries are sorted lexicographically.

Definition 2.5

(four-point condition [11]) A tree metric satisfies the four-point condition and hence defines a tree if and only if the maximum among the Plücker relations,

$$\begin{aligned} w(i,j) \odot w(k, \ell ),\qquad w(i,k) \odot w(j, \ell ),\qquad w(i, \ell ) \odot w(j,k), \end{aligned}$$
(3)

is attained at least twice for \(1 \le i< j< k < \ell \le N\), or, equivalently, if

$$\begin{aligned} w(i,j) \odot w(k, \ell ) \le w(i,k) \odot w(j, \ell ) \boxplus w(i, \ell ) \odot w(j,k) \end{aligned}$$
(4)

for all distinct \(i, j, k, \ell \in [N]\).

The above technical condition characterizes phylogenetic trees; in particular, the space of phylogenetic trees with N leaves\({\mathcal {T}}_N\), is the collection of all n-tuples \(\{w(i,j)\}_{1 \le i < j \le N}\) that satisfy the four-point condition (4), or equivalently, where the maximum among (3) is achieved at least twice. For examples and counterexamples of the four-point condition with illustrations, see [29].

The coincidence between the space of phylogenetic trees and tropical geometry arises through the four-point condition as follows. Speyer and Sturmfels [37] identify a homeomorphism between \({\mathcal {T}}_N\) and a tropical version of the Grassmannian of 2-planes in N dimensions: the Grassmannian may be mapped to a projective variety via the Plücker embedding, which, when interpreted tropically, gives the homeomorphism in [37] by recovering the four-point condition defining phylogenetic trees. This endows the space of phylogenetic trees with a tropical geometric structure; in particular, the space of phylogenetic trees is a tropical variety.

The four-point condition may be strengthened to define an important subclass of trees as follows.

Definition 2.6

(three-point condition [20]) A tree metric satisfies the three-point condition and hence defines a tree ultrametric if and only if the maximum among

$$\begin{aligned} w(i,j), \quad \ w(i,k), \quad \ w(j,k) \end{aligned}$$

is attained at least twice for \(1 \le i< j < k \le N\).

The space of tree ultrametrics with N leaves, \({\mathcal {U}}_N\), is the collection of all n-tuples \(\{ w(i,j) \}_{1 \le i < j \le N}\) satisfying the three-point condition. A rooted phylogenetic tree T is equidistant if the distance from every leaf to its root is constant.

Proposition 2.7

[29, Prop. 12] A tree metric w for a phylogenetic tree T is a tree ultrametric if and only if T is equidistant.

2.3 The Tropical Projective Torus

For equidistant trees, since the distance between the root and every leaf is constant, this distance (or the tree’s height) may always be normalized to 1. This idea may be generalized to unrooted trees to normalize the evolutionary time between trees by considering an equivalence relation for tree metrics represented by cophenetic vectors \(x,y \in {\mathbb {R}}^n\):

$$\begin{aligned} x \sim y \ \Leftrightarrow \ x_1 - y_1 = x_2 - y_2 = \ldots = x_n - y_n, \end{aligned}$$

meaning that \(x \sim y\) if and only if all coordinates of their difference \(x - y\) are equal. This equivalence relation generates a quotient space known as the tropical projective torus, denoted by \({\mathbb {R}}^n/{\mathbb {R}}\mathbf{{1}}\), which is the ambient space of tree space, \({\mathcal {U}}_N \subset {\mathcal {T}}_N \subset {\mathbb {R}}^n/{\mathbb {R}}\mathbf{{1}}\). The tropical projective torus \({\mathbb {R}}^n/{\mathbb {R}}\mathbf{{1}}\) may be embedded into \({\mathbb {R}}^{n-1}\) by considering representatives of the equivalence classes with first coordinate equal to zero, \((x_2 - x_1, x_3 - x_1, \ldots , x_n - x_1) \in {\mathbb {R}}^{n-1}\). See [24, 28, 29] for more detail.

2.4 Comparing Trees via Metrics

Metrics are a natural tool for comparing trees and providing a quantitative measure of similarity between trees. Various metrics have been proposed over the past several decades during which quantitative and computational tree studies have been an active research interest.

Some of the most popular metrics between trees are those that maintain characteristics of Euclidean distance in the inherently non-Euclidean setting of tree space, such as an inner product structure. Some examples of well-known inner product distances between trees are the path difference, quartet distance, and Robinson–Foulds distance [34]. However, these are known to suffer from structural errors, since many pairs of trees measure the same distance apart under these metrics; as well as interpretive errors, since the existence of large distances between trees does not necessarily mean that there are large differences between shared ancestry of leaves [39]. Other metrics use the cophenetic vector representation of tree metrics, treating them simply as points in Euclidean space, and then using the \(\ell ^\infty \) distance in \({\mathbb {R}}^n\) [12].

Remark 2.8

Notice that the image of the linear mapping from \({\mathbb {R}}^N\) to \({\mathbb {R}}^n\) given by

$$\begin{aligned} (x_1, \ldots , x_N) \mapsto x_i - x_j, \end{aligned}$$
(5)

for all pairs \(i < j\), is isomorphic to the tropical projective torus. Under such a mapping, it is then possible to work in \({\mathbb {R}}^n\) equipped with the \(\ell ^\infty \) metric as in [5, 8, 9].

Other popular and well-known metrics include the nearest neighbor interchange metric [44], subtree transfer distance [3], and variational distance [40]. There also exist metrics that connect the subfield of mathematical phylogenetics to various other subfields of pure mathematics, such as the algebraic metric [2], which is based on a group structure; Munch and Stefanou [30] also show that the \(\ell ^\infty \) metric applied to trees [12] is in fact an interleaving distance from applied and computational topology.

BHV Space and the Geodesic Metric. We focus and provide more detail on the geometric interpretation of tree space proposed by Billera et al. [10] for two main reasons. First, the tropical geometric approach is the most comparable to the BHV setting since it is also geometric in nature and also defines a moduli space. Second, previous work which this paper builds upon is in direct comparison to BHV space; we follow suit for consistency.

In BHV space, \({\mathcal {T}}_N^{\mathrm {BHV}}\), phylogenetic trees are represented as Euclidean vectors; the entries in the vectors are given by internal edge lengths of the trees, external edge lengths are disregarded. For a phylogenetic tree with N leaves, there are at most \(2N-2\) edges: N terminal edges connecting to leaves, and at most \(N-2\) internal edges. Trees in BHV space are therefore represented as vectors in \({\mathbb {R}}^{N-2}\), for a given tree topology. The space of phylogenetic trees is then a collection of \((2N-3)!!\) many Euclidean orthants; each orthant may be regarded as the polyhedral cone of \({\mathbb {R}}^{N-2}\) with all nonnegative coordinates, which correspond to the internal edge lengths in a tree.

On the orthant boundaries, there is at least one zero coordinate that occurs; orthant boundaries represent trees with collapsed internal edges. The orthants are joined along the orthant boundaries. In general, tree topologies of the orthants determine the adjacency: boundary trees from two different orthants (i.e., trees with two different topologies) may characterize the same polytomic topology (or split) so these two orthants are grafted together along this boundary when the trees from each topology with collapsed internal edges coincide. Two adjacent orthants, therefore, represent similar, yet distinct, tree topologies. Orthants are grafted at right-angles, resulting in a stratified space.

The right-angle grafting has a direct implication on the curvature of BHV space; BHV space satisfies the \(\mathrm {CAT}(0)\) property of flag complexes, and geodesics are thus unique. The geodesic characterizes a metric on BHV space, where the length of the geodesic between any two trees is the distance. Geodesics are computable on BHV space; the geodesic between any two trees represented by their internal edge lengths is first computed, external edges are then factored in afterwards to compute the overall distance. For two trees in the same orthant, the shortest path between them is simply the straight line measured by the Euclidean distance between them. For trees in different orthants, the difficulty arises in establishing the sequence of orthants to traverse to give the shortest distance between the trees. For trees that are not in neighboring orthants and especially when the tree topologies are very different, the geodesic often passes through the origin (or star tree, where all internal edges are collapsed); paths that traverse the origin are referred to as cone paths. For trees with four leaves, the sequence of orthants containing the shortest path between two trees can be systematically computed by a grid search, but for larger trees, such a search is intractable. Owen and Provan [31] give the fastest available algorithm to date to find the geodesic path between any two trees in BHV space, which runs in quartic time in the number of leaves N.

2.5 Palm Tree Space

Monod et al. [29] present an alternative geometric construction of phylogenetic tree space based on tropical geometry and study its analytic and topological properties with the aim of statistical inference and data analysis in mind. Trees are represented by cophenetic vectors (2); external edge lengths are thus included. Endowed with the tropical metric, the resulting metric moduli space is referred to as palm tree space (tropical tree space).

The tropical metric is a generalized Hilbert projective metric function and arises in other tropical geometric settings, e.g., [1, 13]. It has also been used in previous work studying phylogenetic trees [25, 26, 45]. The tropical metric is combinatorial in nature and is given by the difference between the maximum and minimum of the differences between the tree coordinates; it is a proper metric [29]. This metric also enjoys other interpretations following the relationship of isomorphism discussed in Remark 2.8; in particular, restricting to the image of the map (5), the tropical metric is precisely the \(\ell ^\infty \) metric.

Under the tropical metric, properties that are desirable for statistical inference (such as hypothesis testing) and exact probabilistic studies (such as concentration inequalities and convergence studies) are satisfied and well defined. Geodesics, however, are not unique; there are infinitely many geodesics between any two points. This indicates a more complex geometry than the \(\mathrm {CAT}(0)\) structure of BHV space. Lee et al. [24] use optimal transport theory to define and study the Wasserstein distances on the tropical projective torus and thus give an algorithm to compute the set of all infinitely-many geodesics on the tropical projective torus.

3 Structure and Geometry of Tropical Geometric Tree Space

BHV space and palm tree space are both moduli spaces and are both inherently geometric constructions. In this section, for comparative purposes and to present the framework of our main results, we study the structure and geometry of the tropical geometric interpretation of phylogenetic tree space.

3.1 Polyhedral Structure

In the same way that \({\mathcal {T}}_N^{\mathrm {BHV}}\) is constructed as the union of polyhedra, where each polyhedron corresponds to one distinct tree topology, the structure of \({\mathcal {T}}_N\) interpreted tropically is also given by such a union.

Proposition 3.1

[28, Prop. 4.3.10] The space \({\mathcal {T}}_{N}\) is the union of \((2N-5)!!\) polyhedra in \({\mathbb {R}}^n/{\mathbb {R}}\mathbf{{1}}\) with dimension \(N-3\).

As in BHV space, in tropical geometric tree space, each polyhedron may be considered as a polyhedral cone of \({\mathbb {R}}^{N-3}\) with all nonnegative coordinates corresponding to the cophenetic vector representation of trees. Here, the cone in consideration is the usual convex cone as a subset of a vector space on an ordered field, closed under linear combinations with positive coefficients (or equivalently, the set spanned by conical combinations of vectors).

Fig. 1
figure 1

The Petersen graph depicting the 15 cones in \({\mathcal {T}}_{5}\)

Example 3.2

When \(N=5\), \({\mathcal {T}}_5\) has \(5!!=15\) cones, which correspond to the edges of the Petersen graph, depicted in Fig. 1. Here, the root is considered as a leaf (see Remark 2.3 above), and the other leaf labels are numbered 1 through 4. The Petersen graph here is illustrative and represents the configuration of the polyhedra according to tree topologies; the edges represent the cones corresponding to a tree topology, the nodes of the graph represent the commonality between the coinciding edges (i.e., between two tree topologies).

To interpret the correspondence to trees in this Petersen graph, consider the leftmost upper graph vertex on the outer hexagon and notice that there are three edges (cones) that meet at this vertex. The figures of the trees associated with these cones (illustrated in the circles) share the property that the edge to leaf 1 is the longest edge, and the remaining three leaves are permuted. Now, consider the graph vertex at the very center of the graph, inside the hexagon: the property common to the trees associated with the three cones meeting at this vertex is that the pair of leaves labeled 1 and 3 are coupled, symmetric, and are joined at the same internal node of the tree that is not the root. The remaining graph vertices may be interpreted in a similar manner, in the sense that they all share one of these two commonalities, under symmetry of and up to leaf labeling scheme. Thus, the ten vertices of the Petersen graph here are given by the number of ways to choose a label for the longest branch length in a tree that connects directly to the root, among four choices of leaf labels (i.e., \(\left( {\begin{array}{c}4\\ 2\end{array}}\right) \)); and the number of ways to choose pairs of leaf labels that are coupled, symmetric, and correspond to the same internal node of the tree that is not directly linked to the root (i.e., \(\left( {\begin{array}{c}4\\ 1\end{array}}\right) \)), so \(\left( {\begin{array}{c}4\\ 2\end{array}}\right) + \left( {\begin{array}{c}4\\ 1\end{array}}\right) = 10\). The intuition of the graph edges as cones lies in the property of closedness under scaling of branch lengths, for each tree type associated with each graph edge in the figure (illustrated in the circles).

The Petersen graph also coincides in the context of BHV space when considering \(N=4\) leaves, as the so-called link of the origin; see [10] for further details.

3.2 Geometry of the Space of Tree Ultrametrics

We now focus on the case of rooted equidistant trees as in [10]. We begin by providing definitions of tropical geometric line and set objects and outlining important properties of these objects in the space of tree ultrametrics.

Notation. For a positive integer N, let \(p_{N}\) be the set of all pairs in [N]. For convenience, we denote a tree ultrametric with N leaves by \((w_{p})_{p\in p_{N}}\), where for \(p=\{i,\!j\}\), \(w_{p} = w(\min (i,\!j),\max (i,\!j))\).

Definition 3.3

Consider the subspace of \(L_N \subseteq {\mathbb {R}}^n\) defined by the linear equations

$$\begin{aligned} w_{ij} - w_{ik}+ w_{jk}=0 \end{aligned}$$
(6)

for \(1\le i< j < k \le N\) in tree metrics w. For the linear equations (6) cutting out \(L_N\), their (max-plus) tropicalization is \(w_{ij}\boxplus w_{ik} \boxplus w_{jk}\): recall that under the trivial valuation, all coefficients are disregarded when tropicalizing. This tropicalization of \(L_N\) is denoted by \({\text {Trop}}(L_N) \subseteq {\mathbb {R}}^{n}/{\mathbb {R}}\mathbf{{1}}\) and is referred to as the tropical linear space with points \((w_{p})_{p\in p_{N}}\) where \(\max {(w_{ij},w_{ik},w_{jk})}\) is obtained at least twice for all triples \(i,j,k\in [N]\).

This is equivalent to the three-point condition for ultrametrics given in Definition 3.3. An observation from tropical geometry gives a correspondence between the tropical linear space \({\text {Trop}}(L_N)\) and the graphic matroid of a complete graph with N vertices.

We have the following geometric characterization of the space \({\mathcal {U}}_N\) and corresponding characterizations of tropical line segments between ultrametrics.

Theorem 3.4

[6] The image of \({\mathcal {U}}_N\) in the tropical projective torus \({\mathbb {R}}^{n}/{\mathbb {R}}\mathbf{{1}}\) coincides with \({\text {Trop}}(L_N)\). That is, \({{\text {Trop}}(L_N)={\mathcal {U}}_N}\).

Definition 3.5

For \(x, y \in {\mathbb {R}}^n/{\mathbb {R}}\mathbf{{1}}\), the tropical line segment with endpoints x and y is the set

$$\begin{aligned} \{ a \odot x \boxplus b \odot y \in {\mathbb {R}}^n/{\mathbb {R}}\mathbf{{1}}\mid a,b \in {\mathbb {R}}\}. \end{aligned}$$

Here, max-plus addition \(\boxplus \) for two vectors is performed coordinate-wise.

The tropical line segment between any two points in \({\mathbb {R}}^n/{\mathbb {R}}\mathbf{{1}}\) is unique and it is a geodesic [29].

Definition 3.6

Let \(S \subset {\mathbb {R}}^n\). If \(a\odot x\boxplus b\odot y\in S\) for all \(x,y\in S\) and all \(a,b\in {\mathbb {R}}\), then S is said to be tropically convex. The tropical convex hull or tropical polytope of a given subset \(V \subset {\mathbb {R}}^n\) is the smallest tropically-convex subset containing \(V \subset {\mathbb {R}}^n\); it is denoted by \(\mathrm {tconv}(V)\). The tropical convex hull of V may be also written as the set of all tropical linear combinations:

$$\begin{aligned} \mathrm {tconv}(V)= & {} \{a_1 \odot v_1 \boxplus a_2 \odot v_2 \boxplus \cdots \boxplus a_n \odot v_n \mid v_1,\ldots ,v_n \in V \\&\qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \text{ and }\; a_1,\ldots ,a_n \in {\mathbb {R}} \}. \end{aligned}$$

Proposition 3.7

For two tree ultrametrics \(T_{1},T_{2}\in {\mathcal {U}}_{N}\), the tropical line segment generated by \(T_{1}\) and \(T_{2}\),

$$\begin{aligned} a \odot T_1 \boxplus b \odot T_2\quad \forall \;a,b \in {\mathbb {R}}, \end{aligned}$$

is contained in \({\mathcal {U}}_N\). In other words, \({\mathcal {U}}_N\) is tropically convex.

Proof

Since \(T_1\) is a tree ultrametric, \(a\odot T_{1}\) remains a tree ultrametric; this is also true for \(b\odot T_{2}\). Thus, we may assume \(a=b=0\).

Suppose \(T_{1}=(w_{\{i,j\}})_{1\le i<j\le N}\) and \(T_{2}=(w'_{\{i,j\}})_{1\le i < j\le N}\), then \(T_{1} \boxplus T_{2}=(w_{\{i,j\}} \boxplus w'_{\{i,j\}})_{1\le i<j\le N}\). Let \(z_{\{i,j\}}= w_{\{i,j\}}\boxplus w'_{\{i,j\}}\). It suffices to show that for any \(1\le i<j<k\le n\), we have that the maximum among \(z_{\{i,j\}},z_{\{i,k\}},z_{\{j,k\}}\) is attained at least twice in order for \(T_1 \boxplus T_2\) to be a tree ultrametric. Let M be this maximum, and set \(M := z_{\{i,j\}}\). Then either \(w_{\{i,j\}}=M\) or \(w'_{\{i,j\}}=M\). If \(w_{\{i,j\}}=M\), at least one of \(w_{\{i,k\}},w_{\{j,k\}}\) is equal to M since \(T_{1}\) is a tree ultrametric, therefore at least one of \(z_{\{i,k\}},z_{\{j,k\}}\) is also equal to M. Similarly, if \(w'_{\{i,j\}}=M\), at least one of \(w'_{\{i,k\}},w'_{\{j,k\}}\) is equal to M, since \(T_{2}\) is a tree ultrametric, therefore at least one of \(z_{\{i,k\}},z_{\{j,k\}}\) is also equal to M. Thus, in either case the maximum among \(z_{\{i,j\}},z_{\{i,k\}},z_{\{j,k\}}\) is attained at least twice, hence \(T_{1} \boxplus T_{2}\) is a tree ultrametric. \(\square \)

This result generalizes outside the context of trees; in general, tropical linear spaces in the tropical projective torus are tropically convex (see [28, Prop. 5.2.8]).

4 Tree Topologies on Tropical Line Segments

In this section, we present our main results, which include a combinatorial study of the variation of tree topologies as well as a notion of invariance within the framework of the tropical line segment. We also give an algorithm for computing tropical line segments.

Note that our study is conducted in the setting of rooted equidistant trees (ultrametrics). The relevance for a study dedicated to ultrametrics specifically in this paper is twofold. First, it allows for a parallel geometric comparison between BHV space and the tropical interpretation of phylogenetic tree space: As mentioned above in Sect. 2.4, the geometric significance of BHV space lies in its construction when only internal edges are considered. Its structure is based on the union of orthants, where each orthant corresponds to a specific rooted tree topology. In other words, the definition of BHV space inherently relies on tree topologies. The tropical construction of tree space, while also polyhedral (see Proposition 3.1), has a more complex algebraic structure, which we explore here by studying rooted equidistant tree topologies and their occurrence within the tropical construction of tree space.

The second motivation for studying ultrametric tree topologies lies in the context of applications: ultrametrics correspond to coalescent processes, which model important biological phenomena, such as cancer evolution [22]. In phylogenomics, the coalescent model is often used to model gene trees given a species tree (see e.g., [23, 35, 43] for further details). The coalescent model takes two parameters, the population size and species depth (i.e., the number of generators from the most recent common ancestor (MRCA) of all individuals at present). The species depth coincides with the height of each gene tree from the root (that is, the MRCA) to each leaf representing an individual in the present time. The output of the coalescent model is a set of equidistant gene trees, since the number of generations from their MRCA to each individual in the present time are the same by model construction. Understanding the structure of ultrametrics is an important step towards the modeling and analysis of coalescent biological processes.

4.1 Tree Variation on Tropical Line Segments

The tropical linear space coincides with the space of tree ultrametrics, and hence, that tropically-convex sets (and therefore tropical line segments) are also fully contained in the space of tree ultrametrics. This endows the space of tree ultrametrics with a tropical structure, and now allows us to study the behavior of points (trees) along tropical line segments. In particular, this allows us to characterize ultrametric tree topologies geometrically, thereby providing a description of the tropically-constructed tree space that is comparable to the geometry of BHV space for rooted trees and zero-length external edges (as originally described by Billera et al. [10]).

The strategy that we implement is largely combinatorial. We first formalize the definition of a tree topology as a collection of subsets of leaves, and use these subsets to define notions of size, and in particular, largest and smallest subsets. Given these upper and lower bounds, we then define an equivalence relation and a partial order that allow us to iteratively and combinatorially partition and compare leaf subsets and tree topologies. This gives us a framework to study shapes of trees: specifically, Theorem 4.15 is a combinatorial theorem that describes the possible tree topologies that exist along a tropical line segment.

Definition 4.1

A tree topology F on [N] is a collection of subsets called clades \(S \subseteq [N]\), where \(2\le |S|\le N-1\) and for any two distinct clades \(S_{1},S_{2}\in F\), exactly one of the following nested set conditions holds:

$$\begin{aligned} S_{1}\subsetneq S_{2},\qquad S_{2}\subsetneq S_{1},\qquad S_{1} \cap S_{2}=\emptyset . \end{aligned}$$
(7)

F is said to be full dimensional if \(|F|=N-2\).

Clades always belong to [N] rather than \([N] \cup \{ 0 \}\), since we may always choose the clade excluding the root (i.e., the leaf with label 0). In this manner, they allow for an alternative representation of trees over tree metric vectors w or matrices W.

Fig. 2
figure 2

Example of an equidistant tree. This tree is also an ultrametric

Example 4.2

For the tree in Fig. 2, there are two ways to express this tree:

  1. 1.

    As a tree ultrametric in \({\mathcal {U}}_5\): (16, 40, 40, 40, 40, 40, 40, 20, 20, 10).

  2. 2.

    As a vector in an ambient space, in terms of lengths of internal edges: \((0, \ldots , 0, 12, 10, 5, 0, \ldots , 0)\), where the values of the nonzero coordinates in this vector are the internal edge lengths leading to clades \(\{A,B\}\), \(\{C,D,E\}\), and \(\{D,E\}\).

In general, using the internal edges to represent trees allows for an iterative construction of a family of clades satisfying one of the nested set conditions (7). In the case of Fig. 2, this family is \(\{A,B\}\), \(\{C, D, E\}\), and \(\{D, E\}\).

The following lemma provides intuition on the definition of full dimensionality given above in Definition 4.1.

Lemma 4.3

Let \(N\ge 2\) be an integer. For any tree topology F on a ground set of N elements, we have \(|F|\le N-2\).

Proof

We proceed by induction on N. When \(N=2\), since \(2 > N-1\), F is necessarily empty because clades S cannot satisfy \(2 \le |S| \le 1\). When \(N=3\), all clades of F must have cardinality 2, because the cardinality is at least 2 and at most 2, and thus are among \(\{1,2\},\{1,3\},\{2,3\}\). But any two of these clades do not satisfy one of the nested set conditions (7). Hence \(|F|\le 1\), and the base case for \(N=2,3\) holds.

Next, suppose Lemma 4.3 holds for \(3\le N\le m\) where \(m\ge 3\). Consider the case when \(N=m+1\): We take all clades S belonging to F that are maximal in terms of inclusion. There are two cases:

  1. (i)

    There is a unique maximal clade \(S_{\max }\) in F: \(|S_{\max }|\le m\) and all clades of F are subsets of \(S_{\max }\). If \(|S_{\max }|\le 2\), then F has a unique clade, which is \(S_{\max }\) and therefore \(|F|=1\le m-1=N-2\); otherwise \(|S_{\max }|\ge 3\). Consider the family \(F\setminus \{S_{\max }\}\) on the ground set \(S_{\max }\). For any \(S\in F \setminus \{S_{\max }\}\), since S is a proper subset of \(S_{\max }\), we have \(2\le |S|\le |S_{\max }|-1\). Since \(F \setminus \{S_{\max }\}\) is still a nested set, it is a tree topology on \(S_{\max }\). By the induction hypothesis, \(|F\setminus \{S_{\max }\}|\le |S_{\max }|-2\le m-2\). Thus, \(|F|=|F \setminus \{S_{\max }\}|+1\le m-1=N-2\) and Lemma 4.3 holds for \(N=m+1\).

  2. (ii)

    There are at least two maximal clades in F: Let these clades be \(S_{1},S_{2},\ldots ,S_{k}\), with \(k\ge 2\), then \(2\le |S_{i}|\le m\) for \(1\le i\le k\). Since F is a nested set, these \(S_{i}\) are pairwise disjoint. So

    $$\begin{aligned} \sum _{i=1}^{m}{|S_{i}|} \le m+1. \end{aligned}$$

    Let \(c_{i}\) be the number of proper subsets of \(S_{i}\) that belong to F. Then \(|F|=k+\sum _{i=1}^{k}{c_{i}}\). Notice that \(c_{i}\) is also the cardinality of a tree topology on \(S_{i}\), so by the induction hypothesis, \(c_{i}\le |S_{i}|-2\). Hence

    $$\begin{aligned} |F| = k+\sum _{i=1}^{k}{c_{i}} \le \sum _{i=1}^{m}{|S_{i}|} - k \le (m+1)-2=N-2. \end{aligned}$$
    (8)

    Lemma 4.3 thus holds for \(N=m+1\).

This concludes the transition step, and the proof. \(\square \)

Conversely, now, we consider the minimal clades of a tree topology F.

Lemma 4.4

Let F be a tree topology on [N]. For any pair \(p\in p_{N}\), let \(F(p)=\{S\in F\mid S\supseteq p\}\). For \(p\in p_{N}\), if \(F(p)\ne \emptyset \), then the intersection of all clades \(S\in F(p)\) is also an element of F(p).

Proof

Suppose \(p\in p_{N}\) and \(F(p)\ne \emptyset \). For any two clades \(S_{1},S_{2}\in F(p)\), since \(p\subseteq S_{1},S_{2}\), then \(S_{1}\) and \(S_{2}\) cannot be disjoint. Thus, by the nested set condition in Definition 4.1, either \(S_{1}\) contains \(S_{2}\) or vice versa. This means that all clades in F(p) form a completely ordered set with respect to set inclusion. Since F(p) is finite, it has a minimal element that must be contained in all other elements. This minimal element is the intersection of all clades in F(p). \(\square \)

Definition 4.5

The minimal element that is the intersection of all clades \(S \in F(p)\) given in Lemma 4.4 is called the closure of p in F. We denote this closure by \({\text {cl}}_{F}(p)\). If \(F(p)=\emptyset \), we set \({\text {cl}}_{F}(p)\) to be [N].

Example 4.6

Let \(F=\{1,2,3,4,5,6\}\) and \(S=\bigl \{ \{1,2,3\}, \{1,2\}, \{1\}, \{5,6\}\bigr \}\). Then \({\text {cl}}_F(2) = \{1,2 \}\), \({\text {cl}}_F(5) = \{5,6\}\), and \({\text {cl}}_F(4) = F\).

Lemma 4.4 intuitively gives us the result that \({\text {cl}}_{F}(p)\) is the minimal subset in \(F \cup [N]\) that contains p.

Given the definition of a tree topology F, and notions of maximal and minimal clades of F, we now proceed to study the behavior of varying tree topologies. We shall construct the setting for such a study via the definitions of an equivalence relation and a partial order on a tree topology F in terms of pairs \(p \in p_{N}\) as follows.

Definition 4.7

Let F be a tree topology on [N]. We define an equivalence relation \(=_{F}\) on \(p_N\) by

$$\begin{aligned} p_1 =_F p_2\ \text {~~if~~}\ {\text {cl}}_{F}(p_1) = {\text {cl}}_{F}(p_2), \end{aligned}$$

and a partial order \(<_{F}\) on \(p_{N}\) by

$$\begin{aligned} p_{1} <_{F} p_{2}\ \text{ if } \ {\text {cl}}_{F}(p_1) \subsetneq {\text {cl}}_{F}(p_2), \end{aligned}$$

for all pairs \(p_1, p_2 \in p_N\).

Lemma 4.8

Let F be a tree topology on [N]. For any distinct elements \(i,j,k\in [N]\), exactly one of the following holds:

$$\begin{aligned} \{i,j\}=_{F} \{i,k\},\qquad \{i,j\}<_{F} \{i,k\},\qquad \{i,k\}<_{F} \{i,j\}. \end{aligned}$$

Proof

Suppose for contradiction that Lemma 4.8 does not hold for some distinct ijk. Then \(F(\{i,j\})\) and \(F(\{i,k\} )\) do not contain each other and there exist \(S_{1},S_{2}\in F\) such that \(S_{1} \in F(\{i,j\}) \setminus F(\{i,k\})\) and \(S_{2} \in F(\{i,k\}) \setminus F(\{i,j\})\). Thus \(j\in S_{1} \setminus S_{2}\) and \(k\in S_{2} \setminus S_{1}\), contradicting that F is a nested set. Hence Lemma 4.8 holds. \(\square \)

Given this framework to compare pairs of elements, we now give two notions of bipartitioning of trees that are closely related. It turns out, as we will see in Theorem 4.11, in the context of tree topologies, they coincide.

Definition 4.9

A rooted phylogenetic tree T is said to be binary if every vertex of T is either a leaf or trivalent.

Definition 4.10

Let F be a tree topology on [N] and \({\bar{F}}=\{S\in F\mid |S|\ge 3\} \cup [N]\). F is said to be bifurcated if for every \(S\in {\bar{F}}\), exactly one of the following holds:

  1. (a)

    there exists a proper subset \(S' \subset S\) such that \(S'\in F\) and \(|S'|=|S|-1\); or

  2. (b)

    there exist two proper subsets \(S',S'' \subset S\) such that \(S',S''\in F\) and \(S'\cup S''=S\).

Note that in (b), we must have that \(S'\cap S''=\emptyset \).

A binary tree is a bifurcating tree that has exactly two descendants stemming from each interior node.

Theorem 4.11

Let F be a tree topology on [N]. The following are equivalent:

  1. (i)

    F is full dimensional;

  2. (ii)

    for \(1\le i<j<k \le N\), two of the pairs \(\{i,j\},\{i,k\},\{j,k\}\) are \(=_{F}\), and the third pair is \(<_{F}\) than the other two F-equivalent pairs;

  3. (iii)

    F is bifurcated;

  4. (iv)

    every phylogenetic tree with tree topology F is binary.

Proof

(iii) \(\Rightarrow \) (ii): Suppose F is bifurcated and consider distinct elements \(i,j,k\in [N]\). By Lemma 4.8, any two of \(\{i,j\},\{i,k\},\{j,k\}\) are comparable with respect to \(=_{F}\) or \(<_{F}\). If the three pairs are all \(=_{F}\), then by Definition 4.7, their closures in F are equal. Let this closure be \(S\in F\cup \{[N]\}\), then \(i,j,k\in S\) and \(|S|\ge 3\), thus \(S\in {\bar{F}}\). Since F is bifurcated, condition (a) or (b) in Definition 4.10 holds for S. If (a) holds, then there exists \(S'\in F\) such that \(S'\) is a proper subset of S with \(|S'|=|S|-1\). In this case, at least two of ijk belong to \(S'\), and the closure of the pair formed by these elements is contained in \(S'\)—a contradiction. So we may assume \(\{i,k\} <_{F} \{i,j\}\).

We now need to show F-equivalence between \(\{i,j\}\) and \(\{j,k\}\): by Definition 4.7, there exists \(S_{1}\in F\) such that \(\{i,k\} \subseteq S_{1}\) but \(\{i,j\}\not \subseteq S_{1}\). Then \(i,k\in S_{1}\) and \(j\notin S_{1}\). Now for any \(S_{2}\in F\), if \(\{j,k\} \subseteq S_{2}\), then \(S_{2}\) and \(S_{1}\) are not disjoint. Since \(j\in S_{2} \setminus S_{1}\), we must have \(S_{1} \subseteq S_{2}\). Then \(i\in S_{2}\), and \(\{i,k\} \subseteq S_{2}\). Since \(\{j,k\}\not \subseteq S_{1}\), by definition, \(\{i,k\} <_{F} \{j,k\}\). In addition, if an element of F is a superset of \(\{i,j\}\), then it also contains k and thus is also a superset of \(\{j,k\}\). Conversely, being a superset of \(\{j,k\}\) implies that it also contains i, and thus is also a superset of \(\{i,j\}\). Therefore \(\{i,j\} =_{F} \{j,k\}\), and (ii) holds.

(ii) \(\Rightarrow \) (iii): Suppose (ii) holds for F. We will show that F is bifurcated: for any subset \(S\in {\bar{F}}\), consider all maximal proper subsets \(M_{1},\ldots ,M_{m}\) of S that are clades in F. For any two such maximal subsets, since neither can be a subset of the other by definition, they must be disjoint. If \(m\ge 3\), we can choose \(i,j,k\in [N]\) from \(M_{1},M_{2},M_{3}\) respectively. Then \({\text {cl}}_{F}(\{i,j\})={\text {cl}}_{F}(\{i,k\})={\text {cl}}_{F}(\{j,k\})=S\) and thus \(\{i,j\} =_{F} \{i,k\} =_{F} \{j,k\}\)—a contradiction. Therefore, m must be either 1 or 2.

If \(m=1\), then \(2\le |M_{1}|\le |S|-1\). Suppose \(|M_{1}|\le |S|-2\), we can choose two elements \(i,j\in S \setminus M_{1}\) and another element \(k\in M_{1}\). Then we also have \({\text {cl}}_{F}(\{i,j\})={\text {cl}}_{F}(\{i,k\})={\text {cl}}_{F}(\{j,k\})=S\) and \(\{i,j\} =_{F} \{i,k\} =_{F} \{j,k\}\)—a contradiction. Hence \(|M_{1}|=|S|-1\) and condition (a) holds. If \(m=2\), we already have disjoint \(M_{1},M_{2}\in F\) that are proper subsets of S. If \(M_{1}\cup M_{2}\ne S\), we may choose \(i\in S \setminus (M_{1}\cup M_{2})\) and \(j\in M_{1},k\in M_{2}\). Then \({\text {cl}}_{F}(\{i,j\})={\text {cl}}_{F}(\{i,k\})={\text {cl}}_{F}(\{j,k\})=S\) and \(\{i,j\} =_{F} \{i,k\} =_{F}\{j,k\}\)—a contradiction. Hence \(M_{1}\cup M_{2} = S\) and condition (b) holds. Hence F is bifurcated.

(i) \(\Rightarrow \) (iii): We proceed by induction on N. When \(N=3\) and F is full dimensional, then \(|F|=1\) and F consists of one 2-element subset. Thus, condition (i) holds for \(\{1,2,3\}\) and F is bifurcated.

Suppose (i) \(\Rightarrow \) (iii) holds for eligible integers less than N. Let F be a full-dimensional nested set on [N], then \(|F|=N-2\). Consider the maximal elements \(S_{1},\ldots ,S_{k}\in F\), \(k\ge 1\), with respect to set inclusion. Then by the case (ii) in the proof of Lemma 4.3, \(|F|\le N-k\). Hence \(k\le 2\).

If \(k=1\), there exists a unique maximal element \(S\in F\) with \(|S|\le N-1\). Then \(F \setminus \{S\}\) is a nested set on the ground set S, and \(N-3=|F \setminus \{S\}|\le |S|-2\le N-1-2=N-3\). So \(|S|=N-1\), and condition (a) holds for [N]. In addition, \(|F\setminus \{S\}|=|S|-2\), so \(F\setminus \{S\}\) is full dimensional. By the induction hypothesis, all elements in \({\bar{F}} \setminus \{S\}\) satisfy either condition (a) or (b). Note that \({\bar{F}}={\bar{F}} \setminus \{S\} \cup \{[N]\}\), so (iii) also holds for F.

If \(k=2\), all equalities hold in (8), so there are two maximal elements \(S_{1},S_{2}\in F\) with \(S_{1}\cap S_{2}=\emptyset \) and \(|S_{1}|+|S_{2}|=N\). So condition (b) holds for [N]. Let \(F_{i}\) be the set of the proper subsets of \(S_{i}\) that belong to F for \(i=1,2\). Then both \(F_{i}\) are full-dimensional tree topologies on their respective ground sets \(S_{i}\). By the induction hypothesis, both \(F_{i}\) are bifurcated and all elements in \({\bar{F}}_{i}\) satisfy either condition (a) or (b). Note that \({\bar{F}}=F\cup \{[N]\}={\bar{F}}_{1}\cup {\bar{F}}_{2} \cup \{[N]\}\), hence F is also bifurcated, which completes the transition step.

(iii) \(\Rightarrow \) (i): We proceed by induction on N. When \(N=3\) and F is bifurcated, then condition (a) holds for \(\{1,2,3\}\) and F only contains one 2-element subset, so F is full dimensional.

Suppose (iii) \(\Rightarrow \) (i) holds for all eligible integers less than N. For any bifurcated nested set F on [N], either condition (a) or (b) holds for the set [N]. If (a) holds, then there exists \(S\in F\) such that \(|S|=N-1\). Then all elements in \(F \setminus \{S\}\) are proper subsets of S and they thus form a nested set on the ground set S. This nested set is also bifurcated, by the induction hypothesis, so it is full dimensional. So \(|F \setminus \{S\}|=|S|-1=N-2\) and \(|F|=|F \setminus \{S\}|+1=N-1\), F is full dimensional.

If condition (b) holds, then there exist disjoint \(S_{1},S_{2}\in F\) such that \(S_{1} \cup S_{2} = [N]\). Let \(F_{i}\) be the elements of F that are proper subsets of \(S_{i}\) for \(i=1,2\). Then \(F=F_1\cup F_2\cup \{S_{1},S_{2}\}\). Each \(F_{i}\) is a nested set on the ground set \(S_{i}\) (and may be empty when \(|S_{i}|=2\)); it is still bifurcated. By the induction hypothesis, \(F_{i}\) is full dimensional and \(|F_{i}|=|S_{i}|-2\). Then \(|F|=(|S_{1}|-2)+(|S_{2}|-2)+2=N-2\), so F is still full dimensional. This completes the transition step.

(iii) \(\Rightarrow \) (iv): Suppose F is bifurcated and a rooted phylogenetic tree T has tree topology F. Let v be a non-leaf node. It suffices to show that v has degree 3. We consider two cases:

  • Suppose v is not the root of T. Then there is a unique path from the root of T to v. Along the path, there is an edge connecting v, and this edge corresponds to a clade S in F. Since F is bifurcated, S satisfies either conditions in Definition 4.9. If there exists a proper subset \(S'\) such that \(S'\) is also a clade of F and \(|S'|=|S|-1\), then all other edges connecting v include one edge connecting to the leaf in \(S\setminus S'\) and one edge corresponding to \(S'\). Otherwise there exist clades \(S',S''\) of F such that \(S'\cup S''=S\), then all other edges connecting v include the two edges corresponding to \(S'\) and \(S''\). In either case, v is trivalent.

  • Suppose v is the root of T. Then v is connected to the virtual leaf 0. Since \([N]\in {\bar{F}}\), [N] satisfies either conditions in Definition 4.9 and v is connecting to two other edges in either case, so v is also trivalent.

(iv) \(\Rightarrow \) (iii): Suppose a binary rooted tree T has tree topology F. For any clade \(S\in {\bar{F}}\), S corresponds to an edge e of T. Let v be the vertex of e with greater distance to the root of T. Since T is binary, v is trivalent and connects to other two edges \(e'\) and \(e''\). Each leaf in S has a unique path to v, which must contain \(e'\) or \(e''\). This admits a partition of S into two nonempty subsets. If both subsets have cardinality of at least 2, then they are both clades of F, and we have \(S'\cap S''=S\). Otherwise one of them is a singleton, say \(S''\), and thus \(S'\) is a clade of F with \(|S'|=|S|-1\). Thus S satisfies the condition in Definition 4.9. For \([N]\in {\bar{F}}\), since T is binary, the root of T is also connected by two edges other than the edge to the virtual leaf. The reasoning above applies to [N], and F is bifurcated. \(\square \)

These concepts of bipartitioning in terms of tree topologies are important in understanding the combinatorial aspects of tree ultrametrics. In addition to the fact that tree ultrametrics are equidistant trees, it is also true that every point along any tropical line segment between two equidistant trees is also itself an equidistant tree. The equivalence relation \(=_F\) and partial order \(<_F\) completely define the set of all ultrametrics for a given tree topology F, which we present and formalize in the following results.

Proposition 4.12

Given a tree topology F on [N], let \({\text {ut}}(F)\) be the set of all ultrametrics in \({\mathcal {U}}_{N}\) corresponding to a tree with tree topology F. Then

$$\begin{aligned} {\text {ut}}(F) \!=\! \{(w_{p})_{p\in p_{N}}\in {\mathcal {U}}_{N} \mid w_{p_{1}}\!=\!w_{p_{2}} \text { if } p_{1} \!=\! _{F} p_{2}, w_{p_{1}}< w_{p_{2}} \text { if }p_{1} <_{F} p_{2}\}. \end{aligned}$$
(9)

Proof

Fix a tree topology F on [N] and a corresponding equidistant tree T. For each internal edge of T indexed by a clade S, let \(\ell (S)>0\) be its length. For the external edge of T, connecting the ith leaf to the root of T, let \(\ell _{i}\) be its length. Let h be the height of T. Then, by definition, the distance of each leaf to the root of T is h. There exists a unique path from the ith leaf to the root, consisting of the external edge connecting the ith leaf, and some internal edges: an internal edge indexed by S appears on this path if and only if the ith leaf and the root are separated by the internal edge itself. This necessarily means that \(i\in S\). Then

$$\begin{aligned} h = \ell _{i} + \sum _{i\in S}{\ell (S)}. \end{aligned}$$
(10)

Next we consider the path connecting the ith and jth leaves. This path consists of the two external edges and some internal edges. An internal edge indexed by S appears on this path if and only if the ith leaf and the jth leaf are separated by the edge. Equivalently, this means that \(|\{i,j\}\cap S|=1\). Hence

$$\begin{aligned} w_{\{i,j\}}&=\ell _{i} + \ell _{j} \!\sum _{|\{i,j\}\cap S|=1}\!{\ell (S)} \\&=2h-\sum _{i\in S}{\ell (S)}-\sum _{j\in S}{\ell (S)}\, +\! \sum _{|\{i,j\}\cap S|=1}\!{\ell (S)} \\&=2h-2\sum _{i,j\in S}{\ell (S)}=2h-2\!\sum _{S\in F(\{i,j\})}\!{\ell (S)}. \end{aligned}$$

Therefore w satisfies the condition defining the set (9).

Conversely, suppose a vector \(w\in {\mathbb {R}}^{n}/{\mathbb {R}}\mathbf{{1}}\) satisfies the conditions defining the set (9). Then the system of linear equations

$$\begin{aligned} w_{\{i,j\}} = 2h - 2\!\sum _{S\in F(\{i,j\})}\!{x_{S}}\ \quad \forall \ \{i,j\}\in p_{N} \end{aligned}$$

has a solution such that \(h\in {\mathbb {R}}\) and \(x_{S}>0\) for all \(S\in F\). By a translation in \({\mathbb {R}}\), we may choose a sufficiently large h such that all \(\ell _{i}\) in (10) are positive. Then w is the ultrametric of an equidistant tree with external edge lengths \(\ell _{i}\) and internal edge lengths \(x_{S}\), whose tree topology is F. \(\square \)

Corollary 4.13

Let F be a tree topology on [N] and \(w\in {\text {ut}}(F)\). Then for any pairs \(p,q\in p_{N}\), if \(p\cap q \ne \emptyset \), then \(w_{p}=w_{q}\) implies \(p=_{F} q\) and \(w_{p} < w_{q}\) implies \(p <_{F} q\).

Proof

If \(p=q\), then \(w_{p}=w_{q}\) holds and \(p =_{F} q\) also holds. Otherwise we may assume \(p=\{i,j\}\) and \(q=\{i,k\}\). By Lemma 4.8, one of the following relationships holds: \(p<_Fq\), or \(p =_{F}q\), or \(q<_{F}p\). By Proposition 4.12, these three relationships imply \(w_{p}<w_{q}\), or \(w_{p}=w_{q},\) or \(w_{p}>w_{q}\) respectively. Hence the converse implications also hold. \(\square \)

So far, we have introduced means to study tree structures by studying subsets of leaves and iteratively dividing and comparing these subsets. We have also determined the set of tree ultrametrics defined by the comparison framework set up in Definition 4.7. Given this framework, we now determine when we have compatibility of sets in order to present our combinatorial result that gives all possible tree topologies along a tropical line segment.

We note that the geometric and combinatorial procedure we present is a natural approach that has been previously implemented in other tree settings and, more generally, in finite metric spaces, e.g., by Bandelt and Dress [7, 15]. Our approach differs in two important ways: firstly, we consider the infinite space of all sets of phylogenetic trees, and secondly, our study is fundamentally tropical, since we use the framework of tropical line segments.

Definition 4.14

Let \(F_{1}\) and \(F_{2}\) be tree topologies on [N]. Define the set of compatible tree topologies of \(F_{1},F_{2}\) to consist of tree topologies F where there exist tree ultrametrics \(w_{1}\in {\text {ut}}(F_{1})\) and \(w_{2}\in {\text {ut}}(F_{2})\), such that the tree ultrametric \(w_{1} \boxplus w_{2} \in {\text {ut}}(F)\). We denote this set by \(C(F_{1},F_{2})\).

Theorem 4.15

Let \(F_{1}, F_{2}, F\) be full-dimensional tree topologies on [N]. If \(F\in C(F_{1},F_{2})\), then any equivalence class \(C\subseteq p_{N}\) with respect to \(=_{F}\) is contained in an equivalence class with respect to either \(=_{F_{1}}\) or \(=_{F_{2}}\). Put differently, for each \(S\in {\bar{F}}\), there exists either \(S_{1}\in F_{1}\) such that for \(p\in p_{N}\), if \({\text {cl}}_{F}(p)=S\), then \({\text {cl}}_{F_{1}}(p)=S_{1}\); or \(S_{2}\in F_{2}\) such that for \(p\in p_{N}\), if \({\text {cl}}_{F}(p)=S\), then \({\text {cl}}_{F_{2}}(p)=S_{2}\).

Proof

Suppose \(F_{3}\in C(F_{1},F_{2})\). There exist ultrametrics \(w^{1},w^{2},w^{3}\) such that for \(p\in p_{N}\), \(w^{3}_{p}=\max (w^{1}_{p},w^{2}_{p})\) and \(w^{i}\in {\text {ut}}(F_{i})\) for \(i=1,2,3\). Choose \(S\in {\bar{F}} =\{S\in F\mid |S|\ge 3\} \cup [N]\). By Theorem 4.11, F is bifurcated, so condition (a) or (b) of Definition 4.10 holds for S. If (a) holds, we set \(X=S'\) and \(Y=S \setminus S'\); if (b) holds, we set \(X=S_{1}\) and \(Y=S_{2}\). Then for \(p=\{i,j\}\in p_{N}\), \(\mathrm {cl}_{F}(p)=S\) if and only if \((i,j)\in X\times Y\) or \((j,i)\in X\times Y\). Let \(M=w^{3}_{\{ i,j \}}\) for all \(i\in X\) and \(j\in Y\), then

$$\begin{aligned} \max {(w^{1}_{\{i,j\}},w^{2}_{\{i,j\}})}=M \end{aligned}$$
(11)

for all \(i\in X\) and \(j\in Y\).

Consider a complete, bipartite graph \(G := K_{|X|,|Y|}\) with vertices \(X\cup Y\). Recall that the vertices of a bipartite graph can be partitioned into two disjoint, independent sets where every graph edge connects a vertex in one set to one in the other. Thus, for \((i,j)\in X\times Y\), if \(w^{1}_{\{i,j\}}=M\), then we call the edge (ij) of G pink; if \(w^{2}_{\{i,j\}}=M\), then we call the edge (ij) of G purple. Then, each edge in G is pink, purple, or both pink and purple. We claim that in fact, either all edges of G are pink, or all edges of G are purple.

Suppose there exists a non-pink edge \((i,j)\in X\times Y\) in G. Then this edge is purple: \(M=w^{2}_{\{i,j\}}\ne w^{1}_{\{i,j\}}\). By (11), \(w^{1}_{\{i,j\}} < M\). For any other element \(j'\in Y,j'\ne j\), if \((i,j')\) is not purple, then \(w^{2}_{\{i,j'\}}<M=w^{1}_{\{i,j'\}}\). Note that \(w^{1}_{\{i,j\}} < w^{1}_{\{i,j'\}} \), thus by Corollary 4.13, \(\{i,j\} <_{F_{1}}\{i,j'\}\). Similarly, since \(w^{2}_{\{i,j'\}} < w^{2}_{\{i,j\}}\), we have \(\{i,j'\} <_{F_{2}} \{i,j\}\). By Theorem 4.11, \(\{j,j'\}=_{F_{1}} \{i,j'\}\) and \(\{j,j'\}=_{F_{2}} \{i,j\}\). Then \(w^{1}_{\{j,j'\}}=w^{2}_{\{j,j'\}}=M\) and \(w_{\{j,j'\}}=M\). By Corollary 4.13, this means that \(\{i,j\} =_{F} \{i,j'\} =_{F} \{j,j'\}\), which contradicts that F is full dimensional. Therefore \((i,j')\) must be purple. Symmetrically, for any \(i'\in X\) with \(i'\ne i\), \((i',j)\) must be purple. Then for such \(i'\) and \(j'\), we have

$$\begin{aligned} w^{2}_{\{i,j\}} = w^{2}_{\{i,j'\}} = w^{2}_{\{i',j\}} = M. \end{aligned}$$

By Corollary 4.13, we have \(\{i,j\} =_{F_{2}} \{i,j'\} =_{F_{2}} \{i',j\}\). Since \(F_{2}\) is full dimensional, Theorem 4.11 gives us that \(\{j,j'\} <_{F_{2}} \{i,j\} =_{F_{2}} \{i,j'\} \). Then \(\{j,j'\} <_{F_{2}} \{i',j\}\), and thus \(\{i',j'\} =_{F_{2}} \{i',j\}\). Hence \(w^{2}_{\{i',j'\}}=M\) and the edge \((i',j')\) in G is purple too. So all edges in G are purple, thus proving our claim.

Finally, if all edges in G are pink, then all \(w^{1}_{\{i,j\}}\) are equal for \((i,j)\in X\times Y\). By Corollary 4.13, all these \(\{i,j\}\) belong to the same equivalence class with respect to \(=_{F_{1}}\); symmetrically, if all edges in G are purple, then all \(w^{2}_{\{i,j\}}\) are equal for \((i,j)\in X\times Y\) and all these \(\{i,j\}\) belong to the same equivalence class with respect to \(=_{F_{2}}\). \(\square \)

There are two important remarks concerning this result to highlight:

Remark 4.16

Theorem 4.15 may still hold when one of the tree topologies is not full dimensional, say \(F_1\). For example, let \(N=5\) and

$$\begin{aligned} F_{1}=\{3,4\}, \qquad F_{2}=\bigl \{\{1,4\}, \{2,3\}, \{1,2,3,4\}\bigr \}. \end{aligned}$$

For \(F=\bigl \{\{1,4\},\{1,3,4\}, \{2,5\}\bigr \}\), \(F\notin C(F_{1},F_{2})\): Suppose \(w^{1}\in {\text {ut}}(F_{1})\) and \(w^{2}\in {\text {ut}}(F_{2})\). Since \({\text {cl}}_{F_{i}}(\{2,5\})=[5]\) for \(i=1,2\), by definition \((w^{i})_{\{2,5\}}=\max _{p\in p_{5}}{(w^{i})_{p}}\) for \(i=1,2\). Let \(w=w^{1}\boxplus w^{2}\). Then \(w_{\{2,5\}}=\max _{p\in p_{5}}{w_{p}}\) also. However, since \(\{2,5\}\in F\), \({\text {cl}}_{F}(\{2,5\})\ne [5]\) and thus \(w\notin {\text {ut}}(F)\). Nevertheless, the conclusion of Theorem 4.15 holds for F, since for \(p\in p_{5}\), we have

$$\begin{aligned} {\text {cl}}_{F}(p)&=[5]&\quad \text {implies}&\quad {\text {cl}}_{F_{1}}(p)&=[5];\\ {\text {cl}}_{F}(p)&=\{1,3,4\}&\quad \text {implies}&\quad {\text {cl}}_{F_{2}}(p)&=\{1,2,3,4\};\\ {\text {cl}}_{F}(p)&=\{1,4\}&\quad \text {implies}&\quad {\text {cl}}_{F_{2}}(p)&=\{1,4\};\\ {\text {cl}}_{F}(p)&=\{2,5\}&\quad \text {implies}&\quad {\text {cl}}_{F_{1}}(p)&=[5]. \end{aligned}$$

Remark 4.17

Theorem 4.15 is a combinatorial approach to searching for all possible tree topologies a tropical line segment of tree ultrametrics can traverse; Example 4.18 illustrates this procedure. However, the converse is not true: given full-dimensional tree topologies satisfying the conditions of Theorem 4.15, it is not always possible to construct tropical line segments that traverse these topologies; see Example 4.19 for details.

Example 4.18

Let \(N=5\) and choose the following two full-dimensional tree topologies on [5]:

$$\begin{aligned} F_{1} =\bigl \{\{1,2,3\},\{1,2\},\{4,5\}\bigr \}\quad \text {and}\quad F_{2} =\bigl \{\{1,3,4,5\},\{1,3,5\},\{1,5\}\bigr \}. \end{aligned}$$

Then the full-dimensional tree topologies in \(C(F_{1},F_{2})\) are \(F_{1},F_{2}\) themselves, and three others:

$$\begin{aligned} \bigl \{\{1, 3, 4, 5\}, \{1, 3, 5\}, \{1, 3\}\bigr \}, \quad&\bigl \{\{1, 3, 4, 5\}, \{4, 5\}, \{1, 3\}\bigr \}, \\&\bigl \{\{1, 2, 3\}, \{1, 3\}, \{4, 5\} \bigr \}. \end{aligned}$$

Note that \(F_{3}=\bigl \{\{1, 2, 3\}, \{2, 3\}, \{4, 5\} \bigr \}\) does not belong to \(C(F_{1},F_{2})\), because \(\{1,2\}\) and \(\{1,3\}\) form an equivalence class with respect to \(=_{F}\), but \(\{1,3\} <_{F_{i}} \{1,2\}\) for \(i=1,2\). This gives an example of the non-existence of certain types of trees.

Fig. 3
figure 3

Tree topologies \(F_{1},F_{2},F\) with 12 leaves in Example 4.19

We now give an example where the converse direction of Theorem 4.15 fails.

Example 4.19

Following Remark 4.17, let \(N=12\). Consider the following three tree topologies \(F_{1},F_{2},F\), depicted in Fig. 5:

$$\begin{aligned} F_{1}&=\bigl \{\{1,2,7,8,9,12\}, \{1,7,9\}, \{2,8,12\},\{1,7\},\{2,8\},\\&\qquad \{3,4,5,6,10,11\}, \{3,5,11\}, \{4,6,10\}, \{3,5\}, \{4,6\} \bigr \} \\ F_{2}&=\bigl \{\{1,2,3,4,9,10\},\{2,3,4,9,10\},\{2,3,4,10\}, \{3,4,10\}, \{3,10\},\\&\qquad \{5,6,7,8,11,12\},\{5,7,12\},\{6,8,11\},\{5,7\},\{6,8\} \bigr \} \\ F&= \bigl \{\{1,2,3,4,9,10\}, \{1,2,9\}, \{3,4,10\}, \{1,9\}, \{3,10\},\\&\qquad \{5,6,7,8,11,12\}, \{5,6,11\},\{7,8,12\}, \{5,11\},\{7,12\}\bigr \}. \\ \end{aligned}$$

Note that \(|F_{1}|=|F_{2}|=|F|=10\), so \(F_{1},F_{2},F\) are all full dimensional. Moreover, Theorem 4.15 holds for F, since for \(p\in p_{12}\), we have

$$\begin{aligned} {\text {cl}}_{F}(p)&=[12]&\quad \text {implies}&\quad {\text {cl}}_{F_{2}}(p)&=[12];\\ {\text {cl}}_{F}(p)&=\{1,2,3,4,9,10\}&\quad \text {implies}&\quad {\text {cl}}_{F_{2}}(p)&=\{1,2,3,4,9,10\};\\ {\text {cl}}_{F}(p)&=\{5,6,7,8,11,12\}&\quad \text {implies}&\quad {\text {cl}}_{F_{2}}(p)&=\{5,6,7,8,11,12\};\\ {\text {cl}}_{F}(p)&=\{1,2,9\}&\quad \text {implies}&\quad {\text {cl}}_{F_{1}}(p)&=\{1,2,7,8,9,12\};\\ {\text {cl}}_{F}(p)&=\{3,4,10\}&\quad \text {implies}&\quad {\text {cl}}_{F_{2}}(p)&=\{3,4,10\};\\ {\text {cl}}_{F}(p)&=\{5,6,11\}&\quad \text {implies}&\quad {\text {cl}}_{F_{1}}(p)&=\{3,4,5,6,10,11\};\\ {\text {cl}}_{F}(p)&=\{7,8,12\}&\quad \text {implies}&\quad {\text {cl}}_{F_{2}}(p)&=\{5,6,7,8,11,12\};\\ {\text {cl}}_{F}(p)&=\{1,9\}&\quad \text {implies}&\quad {\text {cl}}_{F_{1}}(p)&=\{1,7,9\};\\ {\text {cl}}_{F}(p)&=\{3,10\}&\quad \text {implies}&\quad {\text {cl}}_{F_{2}}(p)&=\{3,10\};\\ {\text {cl}}_{F}(p)&=\{5,11\}&\quad \text {implies}&\quad {\text {cl}}_{F_{1}}(p)&=\{3,5,11\};\\ {\text {cl}}_{F}(p)&=\{7,12\}&\quad \text {implies}&\quad {\text {cl}}_{F_{2}}(p)&=\{5,7,12\}. \end{aligned}$$

However, \(F\notin C(F_{1},F_{2})\): suppose there exist \(w\in {\text {ut}}(F)\), \(w^{1}\in {\text {ut}}(F_{1})\), \(w^{2}\in {\text {ut}}(F_{2})\) such that \(w = w^{1} \boxplus w^{2}\). Note that we have \(\{1,2\} =_{F} \{2,9\}\) and \(\{1,2\} =_{F_{1}} \{2,9\}\) but \(\{2,9\} <_{F_{2}} \{1,2\}\). Then

$$\begin{aligned} w^{2}_{\{2,9\}} < w^{2}_{\{1,2\}} \le \max {\bigl (w^{1}_{\{1,2\}},w^{2}_{\{1,2\}} \bigr )} = w_{\{1,2\}} = w_{\{2,9\}}=\max {\bigl (w^{1}_{\{2,9\}},w^{2}_{\{2,9\}} \bigr )}. \end{aligned}$$

Hence \(w^{1}_{\{2,9\}}>w^{2}_{\{2,9\}}\), and we have

$$\begin{aligned} w^{1}_{\{1,2\}} = w^{1}_{\{2,9\}} = w_{\{2,9\}}=w_{\{1,2\}}=\max \big (w^{1}_{\{1,2\}},w^{2}_{\{1,2\}} \big ). \end{aligned}$$

Thus,

$$\begin{aligned} w^{1}_{\{1,2\}} \ge w^{2}_{\{1,2\}}. \end{aligned}$$
(12)

Similarly, \(\{4,10\} <_{F_{1}} \{3,4\}\) implies that

$$\begin{aligned} w^{2}_{\{3,4\}} \ge w^{1}_{\{3,4\}}. \end{aligned}$$
(13)

We also have \(\{6,11\} <_{F_{2}} \{5,6\}\), which implies that

$$\begin{aligned} w^{1}_{\{5,6\}} \ge w^{2}_{\{5,6\}}, \end{aligned}$$
(14)

and \(\{8,12\} <_{F_{1}} \{7,8\}\) implies that

$$\begin{aligned} w^{2}_{\{7,8\}} \ge w^{1}_{\{7,8\}}. \end{aligned}$$
(15)

Then Proposition 4.12 together with (12), (13), (14), and (15), we have the following chain of inequalities:

$$\begin{aligned} w^{1}_{\{1,2\}} \ge w^{2}_{\{1,2\}} > w^{2}_{\{3,4\}} \ge w^{1}_{\{3,4\}} = w^{1}_{\{5,6\}} \ge w^{2}_{\{5,6\}} = w^{2}_{\{7,8\}} \ge w^{1}_{\{7,8\}} = w^{1}_{\{1,2\}}, \end{aligned}$$

a contradiction. Hence such tree ultrametrics \(w, w^{1}, w^{2}\) do not exist.

4.2 Symmetry on Tropical Line Segments

In contrast to the previous result, which dealt with how tree topologies vary along tropical line segments, we now turn our focus to understanding when and how invariance arises in the space of ultrametrics. To do this, we define the notion of symmetry on ultrametrics in terms of leaf relabeling. The natural setting for such a study is the action of the symmetric group \({\text {Sym}}(N)\) on N labels on [N], given by permuting the coordinates (positions) of the labels of the leaves.

In our study, we consider the map \(\varSigma :{\mathcal {U}}_N \times {\text {Sym}}(N) \rightarrow {\mathcal {U}}_N \) defined by

$$\begin{aligned}\varSigma (w, \sigma ) = \bigl (w_{\{\sigma _1,\sigma _2\}}, w_{\{\sigma _1,\sigma _3\}}, \ldots , w_{\{\sigma _{N-1},\sigma _{N}\}} \bigr ),\end{aligned}$$

where w is an ultrametric and \(\sigma \in {\text {Sym}}(N)\) is an Nth-order permutation of the symmetric group.

Definition 4.20

Let T be an equidistant tree with N leaves and let \(w_T \in {\mathcal {U}}_N\) be a tree metric associated with T. Define the equivalence relation \(\sim _{\sigma }\) between equidistant trees T and \(T'\) with N leaves by \(T \sim _{\sigma } T'\) if and only if T and \(T'\) have the same tree topology and branch lengths, but the labels of leaves in \(T'\) are permuted by \(\sigma \in {\text {Sym}}(N)\).

Example 4.21

Let \(T_1\) and \(T_2\) be the equidistant trees shown in Fig. 4. Here, \(T_1 \sim _{\sigma } T_2\), where \(\sigma =(2, 3, 1, 4)\).

Fig. 4
figure 4

\(T_1\) and \(T_2\) in Example 4.21

Lemma 4.22

Let \(T_1, T_2\) be equidistant trees with N leaves. Let \(w^{1}\) be a tree ultrametric for \(T_1\) and \(w^{2}\) be a tree ultrametric for \(T_2\). Then \(T_1 \sim _{\sigma } T_2\) if and only if \(\varSigma (w^{1}, \sigma ^{-1}) = w^{2}\) or equivalently, \(\varSigma (w^{2}, \sigma ) = w^{1}\).

Proof

Suppose \(T_1 \sim _{\sigma } T_2\). Let \(w^{1} = \bigl (w^{1}_{\{1,2\}}, \ldots , w^{1}_{\{N-1,N\}}\bigr )\) and, similarly, \(w^{2} = \bigl (w^{2}_{\{1,2\}}, \ldots , w^{2}_{\{N-1,N\}}\bigr )\). We have that \(w^{1}_{\{i,j\}}\) is the distance from a leaf i to a leaf j on \(T_1\), and \(w^{2}_{\{i,j\}}\) is the distance from a leaf i to a leaf j on \(T_2\), by the definition of a tree metric. Since \(T_1 \sim _{\sigma } T_2\), we have that \(w^{1}_{\{i,j\}} = w^{2}_{\{\sigma _{i}, \sigma _{j}\}}\). Thus, \(\varSigma (w^{1}, \sigma ^{-1}) = w^{2}\).

Now suppose \(\varSigma (w^1, \sigma ^{-1}) = w^{2}\). Then we have \(w^{1}_{\{i,j\}} = w^{2}_{\{\sigma _{i}, \sigma _{j}\}}\) for any pair of leaves \(i, j \in [N]\). Since \(w^{1},w^{2} \in {\mathcal {U}}_N\), there exist equidistant trees \(T_1, T_2\) with N leaves, respectively, by Proposition 2.7. Then, \(w^{1}_{\{i,j\}}\) is the distance from a leaf i to a leaf j on \(T_1\), and \(w^{2}_{\{i,j\}}\) is the distance from a leaf i to a leaf j on \(T_2\), by the definition of a tree metric. Since \(\varSigma (w^{1}, \sigma ^{-1}) = w^{2}\), we have that \(w^{1}_{\{i,j\}} = w^{2}_{\{\sigma _{i}, \sigma _{j}\}}\) for all pair of leaves i and j. Therefore, \(T_1 \sim _{\sigma } T_2\). \(\square \)

Example 4.23

To illustrate Lemma 4.22, we revisit the equidistant trees \(T_1\) and \(T_2\) shown in Fig. 4. Their ultrametrics are

$$\begin{aligned} w^{1} = (0.4,0.8,2, 0.8,2, 2),\qquad w^{2}= (0.8,0.8,2,0.4, 2, 2). \end{aligned}$$

Then we have \(\sigma =(2, 3, 1, 4)\) and \(\sigma ^{-1} = (3, 1, 2, 4)\), thus

$$\begin{aligned} \varSigma (w^{2}, \sigma )= w^{1},\qquad \varSigma (w^{1}, \sigma ^{-1})= w^{2}. \end{aligned}$$

Note that for \(T_1\):

$$\begin{aligned} w^{1}(1, 2)&=w^{2}(\sigma _1, \sigma _2)=w^{2}(2, 3)=0.4,\\ w^{1}(1, 3)&= w^{2}(\sigma _1, \sigma _3)= w^{2}(2, 1)= w^{2}(1, 2)=0.8,\\ w^{1}(1, 4)&= w^{2}(\sigma _1, \sigma _4)= w^{2}(2, 4)=2,\\ w^{1}(2, 3)&=w^{2}(\sigma _2, \sigma _3) = w^{2}(3, 1)= w^{2}(1, 3)=0.8,\\ w^{1}(2, 4)&=w^{2}(\sigma _2, \sigma _4) = w^{2}(3, 4)=2,\\ w^{1}(3, 4)&= w^{2}(\sigma _3, \sigma _4)=w^{2}(1, 4)=2, \end{aligned}$$

and similarly, for \(T_2\):

$$\begin{aligned} w^{2}(1, 2)&=w^{1}(\sigma ^{-1}_1, \sigma ^{-1}_2) = w^{1}(3, 1) = w^{1}(1, 3) =0.8,\\ w^{2}(1, 3)&=w^{1}(\sigma ^{-1}_1, \sigma ^{-1}_3) = w^{1}(3, 2)= w^{1}(2, 3)= 0.8,\\ w^{2}(1, 4)&=w^{1}(\sigma ^{-1}_1, \sigma ^{-1}_4) = w^{1}(3, 4)= 2,\\ w^{2}(2, 3)&= w^{1}(\sigma ^{-1}_2, \sigma ^{-1}_3) = w^{1}(1, 2)=0.4,\\ w^{2}(2, 4)&=w^{1}(\sigma ^{-1}_2, \sigma ^{-1}_4) = w^{1}(1, 4)= 2,\\ w^{2}(3, 4)&=w^{1}(\sigma ^{-1}_3, \sigma ^{-1}_4) = w^{1}(2, 4)=2. \end{aligned}$$

With this definition of symmetry given by permutation of leaf relabeling, we now study how symmetry behaves on tropical line segments. Let \(\varGamma (w^{T})\) be a tropical line segment from the origin \((0, 0,\ldots ,0)\) to the ultrametric \(w^{T} \in {\mathcal {U}}_N\) associated with an equidistant tree T. Also, let \(\varGamma (w^{T}, w^{T_0})\) be a tropical line segment from the ultrametric \(w^{T_0} \in {\mathcal {U}}_N\) associated with an equidistant tree \(T_0\), to the ultrametric \(w^{T} \in {\mathcal {U}}_N\) associated with an equidistant tree T. These definitions give the following result.

Proposition 4.24

Suppose \(T_1\) is an equidistant tree with N leaves and let \(T_2\) be an equidistant tree such that \(T_1 \sim _{\sigma } T_2\). Then

$$\begin{aligned} \varSigma (\varGamma (w^{1}), \sigma ) = \varGamma (w^{2})\quad \text {and}\quad \varSigma (\varGamma (w^{2}), \sigma ^{-1}) = \varGamma (w^{1}). \end{aligned}$$

Proof

Let \(w^{1} =\bigl (w^{1}_{\{1,2\}}, w^{1}_{\{1,3\}}, \ldots , w^{1}_{\{N-1,N\}}\bigr )\) be an ultrametric computed from an equidistant tree \(T_1\), and similarly, \(w^{2}=\bigl (w^{2}_{\{1,2\}}, w^{2}_{\{1,3\}}, \ldots , w^{2}_{\{N-1,N\}}\bigr )\) be an ultrametric computed from an equidistant tree \(T_2\). Order the coordinates of both \(w^1\) and \(w^2\) from the smallest and largest, and let \((w^1_{(1)},\dots ,w^1_{(n)})\) and \((w^2_{(1)},\dots ,w^2_{(n)})\) be the ultrametrics after ordering the coordinates of \(w^{1}\) and \(w^{2}\), respectively, from the smallest to the largest coordinates. By Lemma 4.22, \(\varSigma (w^{1}, \sigma ^{-1}) = w^{2}\) since \(T_1 =_{\sigma } T_2\). Thus, \(w^{1}_{(i)} = w^{2}_{(i)}\) for \(i=1,\dots ,n\). By applying the algorithm in the proof of [28, Prop. 5.2.5] on the line segment from the origin \((0,0,\dots ,0)\) to \((w^{1}_{(1)}, \ldots , w^{1}_{(n)})\), we obtain a tropical line segment from the origin to \(w^{1}\). Since \(w^{1}_{(i)} = w^{2}_{(i)}\) for \(i=1,\dots ,n\), we have that \(\varSigma (\varGamma (w^{1}), \sigma ) = \varGamma (w^{2})\) or equivalently \(\varSigma (\varGamma (w^{2}), \sigma ^{-1}) = \varGamma (w^{1})\). \(\square \)

The following results provide a formalization of invariance under the action of permutation of leaf labels in terms of tree topologies. If two tree ultrametrics have the same topology and branch lengths, but differ by a permutation of leaf labels, and, correspondingly, two other tree ultrametrics have the same properties, and the orbit of the symmetric group action permuting the labels is the same for both sets of leaf-permuted trees, then the tropical line segments connecting these pairs coincide.

Theorem 4.25

Suppose \(T_0\) and \(T'_0\) are equidistant trees with N leaves such that \(T_0 =_{\sigma } T'_0\). Also, suppose T and \(T'\) are equidistant trees with N leaves such that \(T =_{\sigma } T'\). Then

$$\begin{aligned} \varSigma (\varGamma (w^{T}, w^{T_0}), \sigma ) = \varGamma (w^{T'}, w^{T'_0})\quad \text {and}\quad \varSigma (\varGamma (w^{T'}, w^{T'_0}), \sigma ^{-1}) = \varGamma (w^{T}, w^{T_0}). \end{aligned}$$

Proof

Since \(T_0 \sim _{\sigma } T'_0\), we have that the differences \({w^{T}-w^{T_0}}\) and \({w^{T'} - w^{T'_0}}\) are equal after ordering the coordinates of \({w^{T} - w^{T_0}}\) and \({w^{T'} - w^{T'_0}}\) from the smallest and largest. The remainder of the proof follows the proof of Proposition 4.24. \(\square \)

Remark 4.26

Haar measures are a natural generalization of Lebesgue measures on spaces with a specified group structure; they are relevant to fundamental studies in probability theory. By our specification in Definition 4.20 and Theorem 4.25, and the existence of probability measures on the tropical geometric interpretation of tree space [29], there exist Haar measures: the group structure is given by the symmetric group \({\text {Sym}}(N)\) and the invariance is on tropical line segments between ultrametrics.

Corollary 4.27

For \(T_0\) invariant under \(\sigma \), let T and \(T'\) be equidistant trees with N leaves such that \(T \sim _{\sigma } T'\). Then

$$\begin{aligned} \varSigma (\varGamma (w^{T}, w^{T_0}), \sigma ) = \varGamma (w^{T'}, w^{T_0})\quad \text {and}\quad \varSigma (\varGamma (w^{T'}, w^{T_0}), \sigma ^{-1}) = \varGamma (w^{T}, w^{T_0}). \end{aligned}$$
Fig. 5
figure 5

Equidistant trees \(T_1\) and \(T_2\), with tropical line segment (blue line) and the BHV geodesic (red line) for Examples 4.28 and 4.30

Example 4.28

Let \(T_1, T_2\) be equidistant trees in Fig. 5. Here, \(\sigma =\sigma ^{-1}=(4,3,2,1)\). Notice that \(\varSigma (\varGamma (w^{1}, w^{0}), \sigma ) = \varGamma (w^{2}, w^{0})\) and \(\varSigma (\varGamma (w^{2}, w^{0}), \sigma ^{-1}) = \varGamma (w^{1}, w^{0})\). In this figure, the black points represent the trees \(T_1\) and \(T_2\). These trees have the same tree topology and the same branch lengths, but leaves are labeled differently. In BHV space, \(T_1\) and \(T_2\) are distinct trees, and thus belong to different orthants in this example, since there are only two internal edges in these trees: recall that in BHV space, within each orthant, trees are stored by their internal edge lengths, which represent coordinates. The BHV distance between \(T_1\) and \(T_2\) is then the unique geodesic that is the cone path, traversing the origin, illustrated by the red line. (See Fig. 1 for the configuration of \(\mathrm {BHV}_5\) and to see that \(T_1\) and \(T_2\) are not in neighboring orthants.)

We have \(T_1 \sim _{\sigma } T_2\), and the tropical line segment is illustrated by the blue line. See the details in Example 4.30 for an explicit computation of the tropical line segment between these trees. The orange points represent the three remaining trees in the figure: notice that in these trees, there is only one internal edge length, and thus the orange points lie on the 1-dimensional strata partitioning the quadrants. The line segments connecting the points traverse the quadrants, and at every point along the blue lines, there are two internal edge lengths until the subsequent orange point is reached, where one internal edge contracts completely into one internal node.

Notice in this example that the bending points of the tropical line segment (the orange points) exhibit interesting tree topologies, including one (2, 2, 2, 0.8, 2, 2) that exhibits sister taxa. Recall from Sect. 2.4 above that orthant boundaries in BHV space that boundaries correspond to trees with a collapsed internal edge between two orthants with similar tree topologies; this tree then lies on a BHV orthant boundary. Depending on conventions adopted, however, it may not always be a tree topology; if tree topologies are required to be full dimensional, then this tree is not a valid tree topology in BHV space.

4.3 Computing Tropical Line Segments

We now focus our study on the tropical line segment and give an algorithm for its computation. We begin with a remark from Example 4.28, where we see that the tropical line segment is not a cone path; it does not traverse the origin (or star tree), whereas BHV geodesics are often cone paths when orthants are far apart. This observation leads to the following proposition, which uncovers a more subtle behavior of tropical line segments compared to BHV geodesics.

Proposition 4.29

For two points u and v in general position in the tropical projective torus \({\mathbb {R}}^{n}/{\mathbb {R}}\mathbf{{1}}\), the tropical line segment between u and v does not contain the origin.

Proof

(due to Carlos Améndola) Let \(u=(u_1,\dots ,u_{n})\) and \(v=(v_1,\dots ,v_{n})\) be two points in general position in \({\mathbb {R}}^{n}/{\mathbb {R}}\mathbf{{1}}\). The tropical line segment consists of the concatenation of m ordinary line segments, each one having a direction of a zero-one vector [28, Prop. 5.2.5]. The bending points (i.e., the points at which the segments are concatenated) can be computed explicitly via the entries of the difference vector \(\lambda = v - u\). Up to reordering, they are given by

$$\begin{aligned} \lambda _i \odot u \boxplus v \end{aligned}$$

for \(i=1,\dots ,n\) (which include the endpoints u and v). From these expressions we see that in order for 0 to be contained in one of the ordinary line segments that comprise the tropical segment from u to v, the bending points would need to be in a particular arrangement (one must be a scalar multiple of the other), which does not happen because u and v are in general position. \(\square \)

Notice that Proposition 4.29 also follows from the fact that there is a unique tropical line segment passing through two points in general position: we may assume without loss of generality that one of the points is 0 and set the other to be u, let L be the unique tropical line segment passing through 0 and u. Then for any \(v\notin L\), there is no tropical line segment containing u, v, and 0. Hence, the tropical line segment between u and v cannot contain 0.

We now give an algorithm for computing tropical line segments between equidistant trees with N leaves. The algorithm takes as input two ultrametrics: \(w^1 = \bigl (w^1_{\{1, 2\}}, \ldots , w^1_{\{N-1, N\}} \bigr )\) associated with an equidistant tree \(T_1\) with N leaves; and \(w^2 = \bigl (w^2_{\{1, 2\}}, \ldots , w^2_{\{N-1, N\}} \bigr )\) associated with an equidistant tree \(T_2\) with N leaves. It returns the tropical line segment between \(T_1\) and \(T_2\) in \({\mathcal {U}}_N\).

figure a

We remark here that there is a similarity in approach between our algorithm and various results in [8] that combinatorially computes ultrametrics. Bernstein [8, Thm. 3.6] gives a combinatorial description of a finite set of ultrametrics with a tropical convex hull that itself is a set of of ultrametrics; it begins with an ultrametric that is coordinate-wise larger than a vertex of a particular tropical polytope and also “slides” internal nodes down until another candidate vertex is attained, which, however, may not necessarily be a tropical vertex [46]. In our algorithm, various tree topologies are obtained at intermediate steps also by “sliding” internal nodes. The following example illustrates the implementation of Algorithm 1.

Example 4.30

We revisit the equidistant trees \(T_2\) and \(T_1\) from Fig. 5, and compute the tropical line segment (blue line) in the figure using Algorithm 1, from \(T_2\) to \(T_1\). Their ultrametrics are

$$\begin{aligned} w^{2} = (2,2,2,0.8,0.8, 0.4),\qquad w^{1} = (0.4, 0.8,2, 0.8,2, 2). \end{aligned}$$

First, we calculate the difference between \(w^2\) and \(w^1\), \(\lambda ' = (1.6,1.2,0,0,-1.2,-1.6)\), and reorder the elements of \(\lambda '\) from smallest to largest: \(\lambda = (-1.6,-1.2,0,1.2,1.6)\).

  1. 1.

    For \(\lambda _{1} = -1.6\), we have

    $$\begin{aligned} w_1 := \lambda _{1} \odot w^1&= (-1.6+0.4,-1.6+0.8,-1.6+2,-1.6+0.8,\\&\qquad -1.6+2,-1.6+2)= (-1.2,-0.8,0.4,-0.8,0.4,0.4),\\ y_1 := w_1 \boxplus w^2&= \bigl ( \max (-1.2, 2), \max (-0.8, 2), \max (0.4, 2),\max (-0.8, 0.8),\\&\qquad \max (0.4, 0.8),\max (0.4, 0.4) \bigr )= w^2 = (2, 2,2,0.8,0.8,0.4). \end{aligned}$$
  2. 2.

    For \(\lambda _{2} = -1.2\), we have

    $$\begin{aligned} w_2 := \lambda _{2} \odot w^1&= (-1.2+0.4, -1.2+0.8, -1.2+2, -1.2+0.8,\\&\qquad -1.2+2,-1.2+2)= (-0.8, -0.4, 0.8,-0.4,0.8,0.8),\\ y_2 := w_2 \boxplus w^2&= \bigl ( \max (-0.8, 2),\max (-0.4, 2), \max (0.8, 2),\\&\qquad \max (-0.4, 0.8),\max (0.8, 0.8),\max (0.8, 0.4) \bigr )\\&= (2,2,2, 0.8,0.8,0.8). \end{aligned}$$
  3. 3.

    For \(\lambda _{3} = 0\), we have

    $$\begin{aligned} w_3 := \lambda _{3} \odot w^1 = w^1&= (0.4,0.8,2,0.8, 2, 2),\\ y_3 := w_3 \boxplus w^2&= \bigl ( \max (0.4, 2), \max (0.8, 2),\max (2, 2),\max (0.8, 0.8),\\&\qquad \max (2, 0.8),\max (2, 0.4) \bigr )= (2,2,2,0.8,2,2). \end{aligned}$$
  4. 4.

    For \(\lambda _{4} = 1.2\), we have

    $$\begin{aligned} w_4 := \lambda _{4} \odot w^1&= (1.2+0.4,1.2+0.8, 1.2+2, 1.2+0.8,1.2+2,1.2+2)\\&= (1.6,2,3.2,2, 3.2,3.2),\\ y_4 := w_4 \boxplus w^2&= \bigl ( \max (1.6, 2), \max (2, 2),\max (3.2, 2),\max (2, 0.8),\\&\qquad \max (3.2, 0.8),\max (3.2, 0.4) \bigr ) \\&= (2,2,3.2, 2,3.2,3.2)= (0.8,0.8,2,0.8,2,2). \end{aligned}$$
  5. 5.

    For \(\lambda _{5} = 1.6\), we have

    $$\begin{aligned} w_5 := \lambda _{5} \odot w^1&= (1.6+0.4, 1.6+0.8,1.6+2,1.6+0.8,1.6+2,1.6+2)\\&= (2,2.4,3.6,2.4, 3.6,3.6),\\ y_5 := w_5 \boxplus w^2&= \bigl ( \max (2, 2),\max (2.4, 2),\max (3.6, 2),\max (2.4, 0.8),\\&\qquad \max (3.6, 0.8),\max (3.6, 0.4) \bigr )\\&= (2,2.4,3.6,2.4,3.6,3.6)= (0.4,0.8,2,0.8,2,2) = w^1. \end{aligned}$$

The trees \(y_i\) that we obtain for each value of \(\lambda _i\) are shown in sequence in Fig. 6. Notice that \(w^2 = y_1 =_\sigma y_5 = w^1\), and \(y_2 =_\sigma y_4\).

Fig. 6
figure 6

Trees \(y_i\) for \(i=1,\ldots ,5\) given by Algorithm 1 from \(T_2\) to \(T_1\) given in Fig. 5

Currently, the fastest available algorithm to compute BHV geodesics runs in quartic time, \(O(N^4)\) [31].

Proposition 4.31

[28, Prop. 5.2.5] The time complexity to compute the tropical line segment connecting two points in \({\mathbb {R}}^n/{\mathbb {R}}\mathbf{{1}}\) is \(O(n\log n) = O(N^2\log N)\).

Notice that the computational complexity of the tropical line segment corresponds to the dimension of the tropical projective torus in the sense that the number of bending points is linear with respect to the dimension of the tropical projective torus. Computing the BHV metric, on the other hand, depends on the angles formed between paths that pass through points lying in different orthants; these paths connect to form the geodesic in BHV space. In this sense, computing the BHV metric also computes line segments but the computation is based on compatibility of two tree topologies while the computation of the tropical line segment does not depend on the tree topology and only computes line segments based on the coordinates of the ultrametrics.

5 Discussion

In this work, we considered the space of phylogenetic trees in the context of tropical geometry as an alternative framework to BHV space. The construction of BHV space is based on tree topologies, where a Euclidean orthant is assigned to each tree topology. In our paper, we study tree topologies and their occurrence in the tropical geometric phylogenetic tree space. In particular, we use the tropical line segment as a framework for our study. For any two given trees, we compute the tropical line segment between them and prove a combinatorial theorem that describes all tree topologies that occur on this tropical line segment between the two trees. We also provide a notion of invariance on a tropical line segment, based on a permutation of leaf labels on trees; this construction has implications in tropical geometric applications to probability theory, since it provides the existence of Haar measures on phylogenetic tree space. We also give an algorithm to compute the tropical line segment between any two trees, which has a lower computational complexity than the current state-of-the-art for computing geodesics in BHV space. We also show that the tropical line segment does not pass through the origin, whereas in BHV space, for orthants that are far apart from one another, the geodesic is often a cone path. This implies a more subtle and intricate geometry than that of BHV space, which is an interesting avenue for further study.

Our work lays foundations for future studies in both theoretical and applied directions. The behavior of the tropical line segment inspires further questions concerning the geometry of tropical geometric phylogenetic tree space. One example is the study of the curvature of the space; given that general geodesics are not unique in palm tree space (i.e., the tropical geometric tree space endowed with the tropical metric), it differs from the \(\mathrm {CAT}(0)\) geometry of BHV space. The variation of tree topologies in tropical geometric phylogenetic tree space may also be used for statistical studies. For example, when different tree topologies arise via a random data generating processes, an interesting question is to ask whether the the difference in topologies is due to a difference in distributions. Palm tree space is a well-defined probability space [29], so this question may be posed in terms of a statistical hypothesis test. A natural way to measure differences between two objects is via a metric; Colijn and Plazzotta [14] propose a metric on phylogenetic tree shapes, which may be used to define a test statistic.