arXiv:1701.02844v1 [math.CO] 11 Jan 2017

Selecting optimal minimum spanning trees that share a topological
correspondence with phylogenetic trees.
Prabhav Kalaghatgi

Thomas Lengauer

Max Planck Institute for Informatics

Max Planck Institute for Informatics

Saarbrücken

Saarbrücken

prabhavk@mpi-inf.mpg.de

lengauer@mpi-inf.mpg.de
Abstract

Choi et al. (2011) introduced a minimum spanning tree (MST)-based method called CLGrouping,
for constructing tree-structured probabilistic graphical models, a statistical framework that is commonly
used for inferring phylogenetic trees. While CLGrouping works correctly if there is a unique MST, we
observe an indeterminacy in the method in the case that there are multiple MSTs. In this work we
remove this indeterminacy by introducing so-called vertex-ranked MSTs. We note that the effectiveness
of CLGrouping is inversely related to the number of leaves in the MST. This motivates the problem of
finding a vertex-ranked MST with the minimum number of leaves (MLVRMST). We provide a polynomial
time algorithm for the MLVRMST problem, and prove its correctness for graphs whose edges are weighted
with tree-additive distances.

1

Introduction

Phylogenetic trees are commonly modeled as tree-structured probabilistic graphical models with two types
of vertices: labeled vertices that represent observed taxa, and hidden vertices that represent unobserved
ancestors. The length of each edge in a phylogenetic tree quantifies evolutionary distance. If the set of
taxa under consideration contain ancestor-descendant pairs, then the phylogenetic tree has labeled internal
vertices, and is called a generally labeled tree (Kalaghatgi et al., 2016). The data that is used to infer the
topology and edge lengths is usually available in the form of gene or protein sequences.
Popular distance-based methods like neighbor joining (NJ; Saitou and Nei (1987)) and BIONJ (Gascuel,
1997) construct phylogenetic trees from estimates of the evolutionary distance between each pair of taxa.
Choi et al. (2011) introduced a distance-based method called Chow-Liu grouping (CLGrouping). Choi et al.
(2011) argue that CLGrouping is more accurate than NJ at reconstructing phylogenetic trees with large
diameter. The diameter of tree is the number of edges in the longest path of the tree.
CLGrouping operates in two phases. The first phase constructs a distance graph G which is a complete
graph over the labeled vertices where each edge is weighted with the distance between each pair of labeled
vertices. Subsequently a minimum spanning tree (MST) of G is constructed. In the second phase, for each
internal vertex vi of the MST, the vertex set Vi consisting of vi and its neighbors is constructed. Subsequently
a generally labeled tree Ti over Vi is inferred using a distance-based tree construction method like NJ. The
subtree in the MST that is induced by Vi is replaced with Ti .
Distances are said to be additive in a tree T if the distance between each pair of vertices u and v is
equal to the sum of lengths of edges that lie on the path in T between u and v. Consider the set of all
phylogenetic trees T such that the edge length of each edge in each tree in T is strictly greater than zero. A
distance-based tree reconstruction method is said to be consistent if for each {D, T |T ∈ T } such that D is
additive in T , the tree that is reconstructed using D is identical to T . Please note the following well-known
result regarding the correspondence between trees and additive distances. Considering all trees in T , if D is
additive in a tree T then T is unique (Buneman, 1971).

1

We show that if G has multiple MSTs then CLGrouping is not necessarily consistent. We show that
there always exists an MST M such that CLGrouping returns the correct tree when M is used in the second
phase of CLGrouping. We show that M can be constructed by assigning ranks to the vertices in G, and
by modifying standard MST construction algorithms such that edges are compared on the basis of both
edge weight and ranks of the incident vertices. The MSTs that are constructed in this manner are called
vertex-ranked MSTs.
Given a distance graph, there may be multiple vertex-ranked MSTs with vastly different number of leaves.
Huang et al. (2014) showed that CLGrouping affords a high degree of parallelism, because, phylogenetic tree
reconstruction for each vertex group can be performed independently. With respect to parallelism, we define
an optimal vertex-ranked MST for CLGrouping to be a vertex-ranked MST with the maximum number of
vertex groups, and equivalently, the minimum number of leaves.
We developed an O(n2 log n) time algorithm Algo. 1 that takes as input a distance graph and outputs a
vertex-ranked MST with the minimum number of leaves (MLVRMST). The proof of correctness of Algo. 1
assumes that the edges in the distance graph are weighted with tree-additive distances.

2

Terminology

A phylogenetic tree is an undirected edge-weighted acyclic graph with two types of vertices: labeled vertices
that represent observed taxa, and hidden vertices that represent unobserved taxa. Information, e.g., in the
form of genomic sequences, is only present at labeled vertices. We refer to the edge weights of a phylogenetic
tree as edge lengths. The length of an edge quantifies the estimated evolutionary distance between the
sequences corresponding to the respective incident vertices. All edge lengths are strictly positive. Trees are
leaf-labeled if all the labeled vertices are leaves. Leaf-labeled phylogenetic trees are the most commonly used
models of evolutionary relationships. Generally labeled trees are phylogenetic trees whose internal vertices
may be labeled, and are appropriate when ancestor-descendant relationships may be present in the sampled
taxa (Kalaghatgi et al., 2016).
Each edge in a phylogenetic tree partitions the set of all labeled vertices into two disjoint sets which are
referred to as the split of the edge. The two disjoint sets are called to the sides of the split.
A phylogenetic tree can be rooted by adding a hidden vertex (the root) to the tree, removing an edge
e in the tree, and adding edges between the root and the vertices that were previously incident to e. Edge
lengths for the newly added edges must be positive numbers and must sum up to the edge length of the
previously removed edge. Rooting a tree constructs a directed acyclic graph in which each edge is directed
away from the root.
A leaf-labeled phylogenetic tree is clock-like if the tree can be rooted in such a way that all leaves
are equidistant from the root. Among all leaf-labeled phylogenetic trees, maximally balanced trees and
caterpillar trees have the smallest and largest diameter, respectively, where the diameter of a tree is defined
as the number of edges along the longest path in the tree.
The distance graph G of a phylogenetic tree T is the edge-weighted complete graph whose vertices are the
labeled vertices of T . The weight of each edge in G is equal to the length of the path in T that connects the
corresponding vertices that are incident to the edge. A minimum spanning tree (MST) of an edge-weighted
graph is a tree that spans all the vertices of the graph, and has the minimum sum of edge weights.

3

Chow-Liu grouping

Choi et al. (2011) introduced the procedure Chow-Liu grouping (CLGrouping) for the efficient reconstruction
of phylogenetic trees from estimates of evolutionary distances. If the input distances are additive in the
phylogenetic tree T then the authors claim that CLGrouping correctly reconstructs T .
CLGrouping consists of two stages. In the first stage, an MST M of G is constructed. In the second stage,
for each internal vertex v, a vertex group N b(v) is defined as follows: N b(v) is the set containing v and all
the vertices in M that are adjacent to v. For each vertex group, a phylogenetic tree Tv is constructed using

2

distances between vertices in N b(v). Subsequently, the graph in M that is induced by N b(v) is replaced by
Tv (see Fig. 1e for an illustration). Tv may contain hidden vertices which may now be in the neighborhood
of an internal vertex w that has not been visited as yet. If this the case, then we need an estimate of the
distance between the newly introduced hidden vertices and vertices in N b(w). Let hv be the hidden vertex
that was introduced when processing the internal vertex v. The distance from hv to a vertex k ∈ N b(w) is
estimated using the following formula, dhv k = dvk − dvhv .
The order in which the internal vertices are visited is not specified by the authors and does not seem to
be important. CLGrouping terminates once all the internal vertices of M have been visited.
This procedure is called Chow-Liu grouping because the MSTs that are constructed using additive distances are equivalent to Chow-Liu trees (Chow and Liu, 1968), for certain probability distributions. Please
read Choi et al. (2011) for further detail.

4

Indeterminacy of CLGrouping

CLGrouping is not necessarily consistent if there are multiple MSTs. We demonstrate this with the phylogenetic tree T shown in Fig. 1a. For the corresponding distance graph G of T (see Fig. 1b), two MSTs
of G, M1 and M2 are shown in Fig. 1c and Fig. 1d, respectively. The intermediate steps, and the final
result of applying CLGrouping to M1 and M2 are shown in Fig. 1e and Fig. 1f, respectively. CLGrouping
reconstructs the original phylogenetic tree if it is applied to M1 but not if it is applied to M2 .
The notion of a surrogate vertex is central to proving the correctness of CLGrouping. The surrogate
vertex of a hidden vertex is the closest labeled vertex, w.r.t. distances defined on the phylogenetic tree.
CLGrouping will reconstruct the correct phylogenetic tree only if the MST can be constructed by contracting
all the edges along the path between each hidden vertex and its surrogate vertex. Since the procedure that
constructs the MST is not aware of the true phylogenetic tree, the surrogate vertex of each hidden vertex
must selected implicitly. In the example shown earlier, M1 can be constructed by contracting the edges
(h1 , l1 ), and (h2 , l3 ). Clearly there is no selection of surrogate vertices such that M2 can be constructed by
contracting the path between each hidden vertex and the corresponding surrogate vertex.
If there are multiple labeled vertices each of which is closest to a hidden vertex then Choi et al. (2011)
assume that the corresponding surrogate vertex is implicitly selected using the following tie-breaking rule.
Let the surrogate vertex set Sg(h) of a vertex h be the set of all labeled vertices that are closest to h.
If l1 and l2 belong to both Sg(h1 ) and Sg(h1 ), then the same labeled vertex (either l1 or l2 ) is selected
as the surrogate vertex of both h1 and h2 . This rule for selecting surrogate vertices cannot be consistently
applied across all hidden vertices. We demonstrate this with an example. For the tree shown in Fig. 2 we
have Sg(h1 ) = {l1 , l2 }, Sg(h2 ) = {l4 , l5 }, and Sg(h3 )={l1 , l2 , l3 , l4 , l5 }. It is clear that there is no selection
of surrogate vertices that satisfies the tie-breaking rule.

5

Ensuring the consistency of CLGrouping

In order to construct an MST that is guaranteed to have the desired topological correspondence with the
phylogenetic tree, we propose the following tie-breaking rule for selecting the surrogate vertex. Let there be
a total order over the set of all labeled vertices. Let R(l) be the rank of vertex l that is given by the order.
We define the surrogate vertex Sg(h) of h to be the highest ranked labeled vertex among the set of labeled
vertices that are closest to h. That is,
Definition 1.
Sg(h) = min R(l) ,where,
l∈Sg(h)

Sg(h) = min dlh .
l∈L(T )

The inverse surrogate set Sg−1 (l) is the set of all hidden vertices whose surrogate vertex is l.

3

A

l1

2

h2 1

h1

2

l2

1

1

B

l3

4

l1

l2

4

4

4
4

l3

l4

l4

2

The complete graph G constructed
using distances that are additive in T

Phylogenetic tree T

C

D
l2

l1
4

l4

l3

l1

l4

l3
4

2

4

An MST M1 of G

l2

2

4

An MST M2 of G

F

E
l2

l1

l1

l4

l3

l4

l3

l2

l3 4
l4 4 2
l1 l3

l2 4
l3 4 4
l1 l2

l1

2
2

l1

l4

2 l3

l2

3
1

h1

l3

l2

1 l4

h1

l3 2
l4 2 2
h1 l3

l1

l2

2
2

h1

l3

1

1

h2

l2 3
l4 1 4
h1 l2

l1

1

l3

l4

l2

3

3
1

h1

1

l4

Incorrect tree constructed by
applying CLGrouping to M2

Correct tree constructed by
applying CLGrouping to M1

Figure 1: The example used to demonstrate that CLGrouping may not reconstruct the correct tree if there
are multiple MSTs. The phylogenetic tree T that is used in this example is shown in panel a. The distance
graph G of T is shown in panel b. Two MSTs of G, M1 and M2 , respectively, are shown in panels c and
d. Panels e and f show the intermediate steps and the final result of applying CLGrouping to M1 and M2
respectively. CLGrouping reconstructs the original phylogenetic tree if it is applied to M1 , but not if it is
applied to M2 .
l1
1

l2

1

1
1

h1 1
2

h3

h2 1

l5

l4

l3

Figure 2: The phylogenetic tree that is used to demonstrate that the tie-breaking rule as defined by Choi
et al. (2011) cannot be applied in general.
In order to ensure that the surrogate vertices are selected on the basis of both distance from the corresponding hidden vertex and vertex rank, it is necessary that information pertaining to vertex rank is used
when selecting the edges of the MST. We use Kruskal’s algorithm (Kruskal, 1956) for constructing the desired MST. Since Kruskal’s algorithm takes as input a set of edges sorted w.r.t. edge weight, we modify the

4

input by sorting edges with respect to edge weight and vertex rank as follows. It is easy to modify other
algorithms for constructing MSTs in such a way that vertex rank is taken into account.
Definition 2. We define below, what is meant by sorting edges on the basis of edge weight and vertex rank.
Given a edge set E, and a ranking R over vertices in E, let d(u, v) be the weight of the edge {u, v}, and let
R(u) be the rank of the vertex u. Let the relative position of each pair of edges in the list of sorted edges
be defined using the total order <. That is to say, for each pair of edges {a, b} and {c, d},
{a, b} < {c, d}, if and only if
(i) d(a, b) < d(c, d), or if
(ii) d(a, b) = d(c, d) and min{R(a), R(b)} < min{R(c), R(d)}, or if
(iii) d(a, b) = d(c, d) and min{R(a), R(b)} = min{R(c), R(d)} and max{R(a), R(b)} < max{R(c), R(d)}.
The MST that is constructed by applying Kruskal’s algorithm to the edges that are ordered with respect
to weight and vertex rank is called a vertex-ranked MST (VRMST).
Now, we will prove Lemma 1, which is used to prove the correctness of CLGrouping.
Lemma 1. Adapted from parts (i) and (ii) of Lemma 8 in Choi et al. (2011). Given a phylogenetic tree T and
a ranking R over the labeled vertices in T , let G be the distance graph that corresponds to T = (VT , ET ) and
let E≤ be the list of edges of G sorted with respect to edge weight and vertex rank, as defined in Definition 2.
Let M = (VM , EM ) be the VRMST that is constructed by applying Kruskal’s algorithm to E≤ . The surrogate
vertex of each hidden vertex is defined with respect to distance and vertex rank as given in Definition 1. M
is related to T as follows.
(i) If j ∈ VM and h ∈ Sg−1 (j) s.t. h 6= j, then every vertex in the path in T that connects j and h belongs
to the inverse surrogate set Sg−1 (j).
(ii) For any two vertices that are adjacent in T , their surrogate vertices, if distinct, are adjacent in M , i.e.,
for all i, j ∈ VT with Sg(i) 6= Sg(j),
{i, j} ∈ ET ⇒ {Sg(i), Sg(j)} ∈ EM
Proof 1. First we will prove Lemma 1 part (i) by contradiction.
Assume that there is a vertex u on the path between h and j, such that Sg(u) = k 6= j. We have
duk ≤ duj (equality holds only if R(k) < R(j)). Similarly, since Sg(h) = j, we have dhj ≤ dhk (equality
holds only if R(j) < R(k)) We consider all eight positions of k w.r.t. h, u, and j (see Fig. 3).
For case 1 we have
dhj ≤ dhk (since Sg(h) = j)
⇔dhl + dlu + duj ≤ dhl + dhk
⇔dlu + duj ≤ dlk
⇔duj < dul + dlk
⇔duj < duk (contradiction since Sg(u) = k).

For case 2 we have
dhj ≤ dhk (equality holds only if R(j) < R(k))
⇔dhu + dul + dlj ≤ dhu + dul + dlk
⇔dul + dlj ≤ dul + dlk
⇔duj ≤ duk (contradiction since Sg(u) = k).
5

k

k
Case 5

Case 1
l

h

u

j

h

u

j

u

j

k
Case 6

Case 2
u

h

Case 4

k

h

h

u

k

j

l

Case 7
Case 3

h

u

u

h

u=k

k

j

j
Case 8

j

h

j

k

Figure 3: The cases that were considered in the proof of Lemma 1 part (ii). For some phylogenetic tree T
let j be a labeled vertex and let h be a hidden vertex in the inverse surrogate set of j. u is a vertex in the
path between h and j. Each case specifies one of the eight possible positions of a labeled vertex k w.r.t h, u,
and j. Hidden vertices are represented with white circles and labeled vertices are represented with black
circles. Each dashed line represents a path between the two vertices at its end points.
For case 3 we have
dhj ≤ dhk
⇔dhu + duj ≤ dhk
⇔duj < dhk + dhu
⇔duj < duk (contradiction since Sg(u) = k).
For case 4 we have
duk = duj + djk (see Fig. 3 case 4)
⇔duk > duj (contradiction since Sg(u) = k).
For case 5 we have
dhj ≤ dhk (equality holds only if R(j) < R(k))
⇔dhu + duj ≤ dhu + duk
⇔duj ≤ duk (contradiction since Sg(u) = k).
For cases 6,7, and 8, we have
dhj ≤ dhk
⇔dhk + dkj ≤ dhk
⇔dhk < dhk (contradiction).
Now we will prove part (ii) of Lemma 1. Consider the edge {i, j} in ET such that Sg(i) 6= Sg(j). Let Vi
and Vj be the sides of the split that is induced by the edge {i, j}, such that Vi and Vj contain i and j,
respectively. Let Li and Lj be sets of labeled vertices that are defined as Vi ∩ VM and Vj ∩ VM respectively.

6

From part (i) of Lemma 1 we know that Sg(i) ∈ Li and Sg(j) ∈ Lj . Additionally, for any k ∈ Li \{Sg(i)}
and l ∈ Lj \{Sg(j)}, from the definition of surrogate vertex it follows that
dki ≥ dSg(i)i (equality holds only if R(Sg(i)) < R(k))
dlj ≥ dSg(j)j (equality holds only if R(Sg(j)) < R(l))
dkj = dki + dij + dlj
≥ dSg(i)i + dij + dSg(j)j
= dSg(i)Sg(j) .
It is clear that
min{R(k), R(l)} > min{R(Sg(i)), R(Sg(j))},

(1)

dkl ≥ dSg(i)Sg(j) .

(2)

and that

The cut property of MSTs states that given a graph G = (V, E) for each pair V1 , V2 of disjoint sets such
that V1 ∪ V2 = V , each MST of G contains one of the smallest edges (w.r.t. edge weight) which have one
end-point in V1 and the other end-point in V2 .
Note that the vertex-ranked MST M is constructed using edges that are sorted w.r.t. edge weight and
the vertex rank R. From equations (1) and (2) it is clear that among all edges with one end point in Li and
the other end-point in Lj , the edge {Sg(i), Sg(j)} is the smallest edge w.r.t edge weight and vertex rank (see
Definition 2). Since Li and Lj are disjoint sets and Li ∪ Lj = VM , it follows that {Sg(i), Sg(j)} ∈ EM .
CLGrouping can be shown to be correct using Lemma 1 and the rest of the proof that was provided by
Choi et al. (2011). Thus if the distances are additive in the model tree, CLGrouping will provably reconstruct
the model tree provided that the MST that is used by CLGrouping is a vertex-ranked MST (VRMST).
The authors of CLGrouping provide a matlab implementation of their algorithm. Their implementation
reconstructs the model tree even if there are multiple MSTs in the underlying distance graph. The authors’
implementation takes as input a distance matrix which has the following property: the row index, and the
column index of each labeled vertex is equal. The MST that is constructed in the authors implementation
is a vertex-ranked MST, with the rank of each vertex being equal to the corresponding row index of the
labeled vertex. We implemented their algorithm in python with no particular order over the input distances
and were surprised to find out that the reconstructed tree differed from the model tree, even if the input
distances were additive in the model tree.
Depending on the phylogenetic tree, there may be multiple corresponding vertex-ranked MSTs with
vastly different numbers of leaves. In the next section we discuss the impact of the number of leaves in a
vertex-ranked MST, on the efficiency of parallel implementations of CLGrouping.

6

Relating the number of leaves in a VRMST to the optimality
of the VRMST in the context of CLGrouping

In the context of parallel programming, Huang et al. (2014) showed that it is possible to parallelize CLGrouping by independently constructing phylogenetic trees for each vertex group, and later combining them in
order to construct the full phylogenetic tree.
In order to relate the balancedness of a phylogenetic tree to the number of leaves in a corresponding
vertex-ranked MST, we consider clock-like caterpillar trees and maximally balanced trees such that each
hidden vertex of each tree has degree three.
Consider the case in which the phylogenetic tree is a caterpillar tree (least balanced). There exists a
corresponding VRMST which has a star topology that can be constructed by contracting edges between each
7

l4

a

root

l3

l5

l8

l1
l6

h6

l2

b

l7

l5

l4
root

h5

l3

l1

h1

l3
h2

l1

h1

Branch length

Branch length

h4

l7
l8

l2
h6

h2

l4

l1
h5

l6
l2

l5

h3

h3

h4

l5

l4
l3

l8
l1

l6

l2

l2

l3

l4

l5

l6 l7

l8

l6

l1

l2

l3

l4

l5

l6

l8
l7

l7 l8

l7

Figure 4: Both panels show clock-like phylogenetic trees and VRMSTs with the maximum and the minimum
number of leaves, that are constructed by contracting corresponding edges that are highlighted in orange and
blue, respectively. The difference between the maximum and the minimum number of leaves in VRMSTs
is largest for the caterpillar tree shown in panel a, and smallest for the maximally balanced tree shown in
panel b.
hidden vertex and one labeled vertex that is in the surrogate vertex set of each hidden vertex (see Fig 4a).
A star-shaped VRMST has only one vertex group, comprising all the vertices in the VRMST, and does not
afford any parallelism.
Instead, if the VRMST was to be constructed by contracting edges between each hidden vertex h and
a labeled vertex that is incident to h, then the number of the vertex groups would be n − 2, where n is
the number of vertices in the phylogenetic tree. The resulting VRMST would have the minimum number of
leaves (two).
With respect to parallelism, an optimal vertex-ranked MST for CLGrouping is a vertex-ranked MST
with the maximum number of vertex groups, and equivalently, the minimum number of leaves.
Consider a phylogenetic tree T = (VT , ET ) which is maximally balanced. It is clear that the set L(T ) of
labeled vertices of T can be partitioned into a disjoint set C of vertex pairs such that for each vertex pair
{u, v} ∈ C, u and v are adjacent to the same hidden vertex h ∈ VT . Given a vertex ranking R, the surrogate
vertex of h will be maxl∈{u,v} R(l). Thus, independently of vertex ranking, the number of distinct surrogate
vertices will be L(T )/2. Each labeled vertex that is not selected as a surrogate vertex will be a leaf in the
vertex-ranked MST. It follows that all corresponding VRMSTs of T will have L(T )/2 leaves (see Fig 4b).
Whether or not the phylogenetic trees that are estimated from real data are clock-like depends on the
set of taxa that are being studied. Genetic sequences that are sampled from closely related taxa have been
estimated to undergo substitutions at a similar rate, resulting in clock-like phylogenetic trees (dos Reis et al.,
2016). In the context of evolution, trees are caterpillar-like if there is a strong selection; the longest path
from the root represents the best-fit lineage.
In the next section we will present an algorithm for constructing a vertex-ranked MST with the minimum
number of leaves.

8

7

Constructing a vertex-ranked MST with the minimum number
of leaves

We aim to construct a vertex-ranked MST with the minimum number of leaves (MLVRMST) from a distance
graph. An algorithm for constructing a MLVRMST is presented in subsection 7.3. In the following two
subsections we will present two lemmas, which will be used for proving the correctness of the algorithm.

7.1

A common structure that is shared by all MSTs

In this section we will prove the existence of a laminar family F over the vertex set of an edge-weighted
graph G. A collection F of subsets of a set S is a laminar family over S if, for any two intersecting sets in F,
one set contains the other. That is to say, for each pair S1 , S2 in F such that |S1 | ≤ |S2 |, either S1 ∩ S2 = ∅,
or S1 ⊂ S2 .
The vertex sets in F define a structure that is common to each MST of G. Furthermore, F can be
used to obtain an upper bound on the degree of each vertex in a MST. The notion of a laminar family
has been utilized previously by Ravi and Singh (2006), for designing an approximation algorithm for the
minimum-degree MST
Lemma 2. Given an edge-weighted graph G = (V, E) with k distinct weight classes W = {w1 , w2 , . . . , wk },
and an MST M of G, let Fi be the forest that is formed by removing all edges in G that are heavier than wi .
Let Ci be the collection comprising
 the vertex set of each component of Fi . Consider the collection F which
is constructed as follows: F = ∪ki=1 Ci ∪ V . The following is true:
(i) F is a laminar family over V
(ii) Each vertex set in F induces a connected subgraph in each MST of G
Proof. (i). Consider any two vertex sets S1 and S2 in F. Let w1 and w2 be the weights of the heaviest
edges in the subgraphs of M that are induced by S1 and S2 , respectively. Let F1 and F2 be the forests that
are formed by removing all edges in M that are heavier than w1 and w2 , respectively. Let C1 and C2 be the
collections comprising the vertex set of each component in F1 and F2 , respectively.
It is clear that S1 ∈ C1 and S2 ∈ C2 . Consider the case where w1 = w2 . Since C1 =C2 , it follows that
S1 ∩ S2 = ∅. If w1 6= w2 , then without loss of generality, let w1 < w2 . F2 can be constructed by adding to
F1 all edges in M that are no heavier than w2 . Each component in F1 that is not in F2 induces a connected
subgraph in exactly one component of F2 . If S1 ∈ C1 ∩ C2 then S1 ∩ S2 = ∅. Otherwise, if S1 ∈ C1 \C2 , then
S1 is a subset of exactly one set in C2 . This implies that either S1 ⊂ S2 , or S1 ∩ S2 = ∅. Thus F is a laminar
family over V .
(ii). Let Si be the vertex set of a component in the subgraph Gi of G that is created by removing all
edges in Gi that are heavier than wi . It is clear that Si induces a connected subgraph in each minimum
spanning forest of Gi . For each minimum spanning forest there is a corresponding MST of G, such that the
minimum spanning forest can be constructed by removing from the MST all the edges are heavier than wi .
It follows that Si induces a connected subgraph in each MST of G.

7.2

Selecting surrogate vertices on the basis of maximum vertex degree

Lemma 3. We are given a phylogenetic tree T , the corresponding distance graph G = (V, E), and the
laminar family F of the distance graph. Let the subgraph g = (Vg , Eg ) of G contain all edges that are present
in at least one MST of G. Let h be a hidden vertex in T such that there is a leaf l in Sg(h), and h is incident
to l. Let Si be a vertex set in F and let wi be the corresponding edge weight. Then the following holds:
(i) Let Jv be the set of all vertices that are incident to vertex v in g. Let Sv be the smallest sub-collection
of F that covers Jv but not v. Among all MSTs, the maximum vertex degree δmax (v) of v is |Sv |.
(ii) δmax (l) ≤ δmax (v) for each vertex v in Sg(h).
9

Proof. (i). Let Jv = {j1 , j2 , . . . , jk } be the set of all vertices that are incident to v. Let M be some MST of
G. Let Sv = {S1 , S2 , . . . , Sm } be the smallest sub-collection of F that covers Jv and does not include v. Let
Sv contain a set Si that covers multiple vertices in J. Let j1 and j2 be any two vertices in Si . Let wi be the
heaviest weight on the path that joins j1 and j2 in M . The edges {v, j1 } and {v, j1 } are heavier than wi . If
they were not, then we would have v ∈ Si . Since v, j1 and j2 are on a common cycle, each MST of G can
only contain one of the two edges {v, j1 }, and {v, j2 }. It follows that for each set Si ∈ Sv , each MST can
contain at most one edge which is incident to v and to a vertex in Si . Thus the maximum number of edges
that can be incident to v in any MST is the number of vertex sets in Sv , i.e., δmax (v) = |Sv |.
(ii). Let Jl and Jv be the set of all vertices that are incident to l and v in g, respectively. Let j ∈ Jl \Sg(h).
The weight of the edge {j, l} ∈ Eg is given by djl . djh > dvh since j ∈
/ Sg(h). Thus dlj > dlv , and
consequently v ∈ Jl . We have djl = djh + dhl = djh + dhv = djv . Consider the MST M = (VM , EM )
that contains the edges {l, v} and {l, h}. Consider the spanning tree M 0 that is formed by removing {l, h}
from EM and adding {v, h}. M 0 and M have the same sum of edge weights. Thus we also have j ∈ Jv .
Consequently Jl ⊆ Jv . Let Sl and Sv be the smallest sub-collections of F such that Sl covers Jl but does not
contain l, and Sv covers Jv but does not contain v. Sv covers both Jl and Jv since Jl ⊆ Jv . Thus |Sl | ≤ |Sv |.
From part (i), we know that |Sl | = δmax (l) and |Sv | = δmax (v). Thus δmax (l) ≤ δmax (v).

10

7.3

Constructing a minimum leaves vertex-ranked MST

We now give an overview of Algo. 1. Algo. 1 takes as input a distance graph G = (V, E) and computes
δmax for each vertex in V . Subsequently, a ranking R over V is identified such that vertices with lower δmax
are assigned higher ranks. The output of Algo. 1 is the vertex-ranked MST which is constructed using R.
If G is weighted with tree-additive distances then the output of Algo. 1 is a vertex-ranked MST with the
minimum number of leaves (MLVRMST).
An example of a phylogenetic tree, a corresponding MLVRMST, and the output MST M of Algo. 1, is
shown in Fig. 5. M is superimposed with the following: the laminar family F, the subgraph g, and δmax for
each vertex.
l1

a

l2

4

1

l3

4

h1
1

1

h2

l4

1

l2

l1

h3

3

h6

l4

l5

l9

2
2

2
3

l3

l10

h5

h4

4

2

l5

b

1

1

l10

l8
l7
l6

l9

l6

l8
l7

l5
2

l1

c
2

l2

l3

2

l10

4 l6

4

2

l8

3

3

1

l9

l4

4 l7

Figure 5: Panel a shows a generally labeled phylogenetic tree T . Algo. 1 was applied to the distance graph
G of T . Panel b show the output M of Algo. 1 which is a MLVRMST of G. Panel c shows M (in red)
superimposed with the laminar family F, and the graph g which contains all edges of G that are present in
at least one MST. Additionally each vertex has been labeled with the corresponding δmax .

11

Algorithm 1: MinLeavesVertexRankedMST of G
Input: G = (V, E)
Initialize:
For each vertex in V , create a Make-Set object;
Create empty arrays called Ew , W, Efixed , Eflexible , and Eselected ;
Create empty hash tables called CompNbrs and CompGraphs;
Create a hash table called δmax and for each u in V set δmax (u) to zero;
1 E≤ ← array of edges of G that are sorted in order of increasing weight;
2 wold ← weight of the lightest edge;
3 for {u, v} in E≤ do
4
w ← weight of {u, v};
5
if w > wold then
6
Vflexible ← Set();
7
Add w to W ;
8
for {u, v} in Ew do
9
if Find(u) 6= Find(v) then
10
Union(u,v);
11
else
12
Add u to the set Vflexible ;
13
14
15
16
17

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

Vw ← vertices in Ew ;
for u in Vw do
Increase δmax (u) by |CompNbrs(u)|;
CompNbrs ← empty hash table;
Add the set {u, v, Comp(u, w), Comp(v, w)} to the array CompGraphs(Find(u)), for each edge
{u, v} in Ew such that Find(u) equals Find(x) for at least one vertex x in Vflexible ;
Add to Efixed , all the edges in Ew that are not in Eflexible ;
Ew ← empty array;
wold ← w;
if F ind(u)6= F ind(v) then
Add {u, v} to Ew ;
Set Comp(u, w) and Comp(v, w) to Find (u) and Find (v), respectively;
Add Comp(u, w) to the set CompNbr(v);
Add Comp(v, w) to the set CompNbr(u);
If |Ew | is greater than zero, then repeat lines 6 through 18;
Identify a ranking R over V such that vertices with lower δmax are assigned higher ranks;
for CompName in CompGraphs.keys() do
Ecomp ← all edges {Comp(u, w), Comp(v, w)} in CompGraphs(CompName);
To each vertex Comp(u, w) in Ecomp , assign the rank R(u);
E≤comp ← edges in Ecomp sorted w.r.t. vertex rank (see Definition 2; each edge has weight w);
Add to Eselected , each edge in the graph that is constructed by applying Kruskal’s algorithm to
E≤comp ;
Output: M = (V, Efixed ∪ Eselected )

First we prove the correctness of Algo. 1, and subsequently, we derive its time complexity. Algo. 1
makes use of the disjoint-set data structure, which includes the operations: Make-Set, Find, and Union. The
data structure is stored in memory in the form of a forest with self-loops and directed edges. Each directed
edge from a vertex points to the parent of the vertex. A Make-Set operation creates a singleton vertex
that points to itself. Each component in the forest has a single vertex that points to itself. This vertex is
called the root. A Union operation takes as input, the roots of two components, and points one root to the
12

other. A Find operation takes as input a vertex, and returns the root of the component that contains the
vertex. Specifically, we implemented balanced Union, and Find with path compression. For a more detailed
description please read the survey by Galil and Italiano (1991).
Theorem 1. Given as input a distance graph such that the distances are additive in some phylogenetic tree
with strictly positive branch lengths, Algo. 1 constructs a vertex-ranked MST with the minimum number of
leaves.
Proof. Let T = (VT , ET ) be the phylogenetic tree that corresponds to the distance graph G = (V, E). Let
W be the set of weights of edges in E. Let F be the laminar family over V , as defined in Lemma 3. Let
g be the subgraph of G that contains the edges that are present in at least one MST of G. Let M be the
output of Algo. 1.
Each edge in Ew is incident to vertices in different components. Since edges in E are visited in order of
increasing weight, each edge in Ew is present in at least one MST of G.
Let c be the root of the component that is formed after Union operations are performed on each edge in
Ew . Let Ec be the subset of Ew such that each edge in Ec is incident to vertices that are in component c
after all Union operations on Ew have been performed. Let C be the set of components such that each vertex
in Ec is contained in a component in C before any Union operations on Ew have been performed. Define the
component graph GC over C to be the graph whose vertices are elements in C, and whose edges are given by
elements in Ec . It is clear that GC is connected. We now consider the time point after all Union operations
on Ew have been performed.
If GC is a simple graph with no cycles, i.e., |C| = |Ec | − 1, then each edge in Ec must be present in each
MST of G. All edges in each simple, acyclic, component graph, are stored in Efixed . If GC is not simple, or if
it contains cycles, then each edge in GC is stored in CompGraphs(c). Additionally each so-called component
label {Comp(u, w), Comp(v, w)} is also stored in CompGraphs(c). For each vertex u ∈ V the component label
Comp(u, w) is the root of the component that contains u before any union operations have been performed
on edges in Ew . For each component c, the component graph GC is induced by the component edges.
Let S be the smallest sub-collection of the laminar family F such that S covers the neighbors of u
but not u. Let Fw be the subgraph of G that is formed by removing from G all edges that are heavier
than w. Let Nw be the set of vertices in Ew that are adjacent to u. Let Cw be the collection comprising
the vertex set of each component of Fw that contains at least one vertex in Nw . It is easy to see that
Cw ⊂ S. It follows
P that S = ∪w∈W Cw , where W is the set comprising the unique edge weights of G. Thus
δmax (u) = |S| = w∈W |Cw |. Thus the operations in line 15 correctly compute δmax (u).
At this time point all the edges of G have been visited. Subsequently, Algo. 1 selects a vertex ranking R
such that vertices with lower δmax are given higher ranks.
Let Eflexible be the set containing the edges {u, v} that are stored in CompGraphs. Let Kruskal’s algorithm
be applied to the edges in Efixed ∪ Eflexible that are sorted with respect to weight and R, and let the resulting
MST be the vertex-ranked MST MR = (VR , ER ).
Let S be the set of all vertices in Comp(u, w). From Lemma 2 (ii), we know that S induces a connected
subgraph in each MST of G. This implies that, after all the edges that are no heavier than w have been
visited by Algo. 1, the vertex set of the component that contains u is independent of the notion of the
vertex rank that is used to sort the edges. Thus, instead of applying Kruskal’s algorithm to each edge in
Efixed ∪ Eflexible , we can avoid redundant computations by applying Kruskal’s algorithm independently to
each component graph. Consequently, ER = Efixed ∪ Eselected .
From Lemma 3 (ii), we know that, if there is a leaf l in Sg(h), such that {h, l} ∈ ET , then among
all vertices in Sg(h), δmax (l) is smallest. Consequently l has the highest rank in R, when compared to
other vertices in Sg(h). Since the surrogate vertex of h is the highest-ranked vertex in Sg(h), Algo. 1
implicitly selects l as the surrogate vertex of h. Since each leaf in T is adjacent to at most one hidden
vertex, the vertex ranking that is selected by Algo. 1, maximizes the number of distinct leaves that are
selected as surrogate vertices. Contracting the path in T between a hidden vertex and the corresponding
surrogate vertex, increases the degree of the surrogate vertex. Thus, among all vertex-ranked MSTs, M has
the minimum number of leaves.

13

7.4

Time complexity of Algorithm 1

We partition the operations of Algo. 1 into three parts. Part (i) sorts all the edges in E and performs Find
and Union operations in order to select the edges in Efixed and CompGraphs. Part (ii) computes δmax for
each vertex in V , and part (iii) sorts, and applies Kruskal’s algorithm to the edges in each component graph
in CompGraphs.
In part (i) Algo. 1 iterates over the edges in G which are sorted w.r.t. edge weight. G = (V, E) is a fully
connected graph with n vertices and n(n − 1)/2 edges. We used python’s implementation of the Timsort
algorithm (Peters, 2002) which sorts the edges in O(n2 log n) time. Let mf be the number of edges in Efixed ,
and let mc be the number of edges that are in a component graph. It is clear that mf + mc ≤ n(n − 1)/2.
Algo. 1 iterates over each edge in G and performs n(n − 1)/2 + mf + mc Find operations, and n − 1 Union
operations. Since we implemented balanced Union, and Find with path compression, the time-complexity of
these operations is O((n(n−1)/2+mf +mc )(α((n(n−1)/2+mf +mc , n)) = O(n2 (α((n(n−1)/2+mf +mc , n)),
where α((n(n − 1)/2 + mf + mc , n) is the inverse of Ackermann’s function as defined in Tarjan (1975), and
is less than 5 for all practical purposes. The total time complexity of part (i) is O(n2 log n).
The operations in line 15 compute δmax (u) by counting the number of distinct components that cover
the vertices Ju ⊂ Ew , such that each vertex j ∈ Ju is adjacent to u. Assuming that the insertion and
retrieval operations on hash tables, and insertion operations arrays have linear time-complexity, the total
time complexity of part (ii) is O(mf + mc ).
Let the number of component graphs in CompGraphs be k and let the number of edges and vertices in
the ith component graph be mi and ni , respectively. The time complexity of sorting, and applying Kruskal’s
algorithm to mi edges, is O(mi log mi ) + O(mi α(mi , ni )) = O(mi log mi ). The total time complexity of part
(iii) is
k
X

O(mi log mi )

i=1

=O

k
X

!
mi log mi

i=1


= O

k
X

!
mi

i=1



k
X
i=1

mi
P

k
i=1

mi

 log mi 

!
mi
log mi
= O mc
mc
i=1
!
k
X
m2i
≤ O mc log
from Jensen’s inequality
mc
i=1
!
k
X
2
≤ O mc log
mi
k
X

i=1


≤ O mc log

k
X

!2 
mi



i=1

= O(mc log mc )
The total time complexity of Algo. 1 is O(n2 log n) + O(mf + mc ) + O(mc log mc ) = O(n2 log n).

14

8

Computational complexity of the MLVRMST construction problem

Let T be the set of all phylogenetic trees. Let G be the set of edge-weighted graphs, such that the edges
of each graph in G are weighted with distances that additive in some tree in T . Algo. 1 constructs a
MLVRMST of any graph in G, in time O(n2 log n). Thus, for graphs in G, the decision version of the
optimization problem MLVRMST is in the complexity class P. For graphs whose edges are not weighted
with tree-additive distances, the MLVRMST problem may not be in P.
Consider the general optimization problem of constructing an MST with the minimum number of leaves
(MLMST). Since the decision version of MLMST can be verified in polynomial time, MLMST is in NP.
Additionally, it is easy to show that there is a polynomial time reduction from the Hamiltonian path problem
to MLMST. Since the Hamiltonian path problem is in NP-complete, MLMST must be in NP-hard∩NP =
NP-complete.

9

Acknowledgements

We thank Erik Jan van Leeuwen and Davis Isaac for helpful discussions during the early stages of the work
presented here.

10

Funding

PK’s work has been funded in part by the German Center for Infection Research (DZIF, German Ministry
of Education and Research Grants No. TTU 05.805, TTU 05.809).

11

Availability of code

A python implementation of Algo. 1 can be found at
http://resources.mpi-inf.mpg.de/departments/d3/publications/prabhavk/minLeavesVertexRankedMST

References
Buneman, P. 1971. The recovery of trees from measures of dissimilarity. In D. G. Kendall and P. Tautu,
editors, Mathematics in the Archaeological and Historical Sciences, pages 387–395. Edinburgh University
Press, Edinburgh, UK.
Choi, M. J., Tan, V. Y. F., Anandkumar, A., and Willsky, A. S. 2011. Learning Latent Tree Graphical
Models. Journal of Machine Learning Research, 12: 1771–1812.
Chow, C. K. and Liu, C. N. 1968. Approximating discrete probability distributions with causal dependence
trees. IEEE Transactions on Information Theory, IT-14(3): 462–467.
dos Reis, M., Donoghue, P. C. J., and Yang, Z. 2016. Bayesian molecular clock dating of species divergences
in the genomics era. Nature Reviews Genetics, 17(2): 71–80.
Galil, Z. and Italiano, G. F. 1991. Data structures and algorithms for disjoint set union problems. ACM
Computing Surveys, 23(3): 319–344.
Gascuel, O. 1997. BIONJ: an improved version of the NJ algorithm based on a simple model of sequence
data. Molecular biology and evolution, 14(7): 685–695.

15

Huang, F., N., N. U., Perros, I., Chen, R., Sun, J., and Anandkumar, A. 2014. Scalable Latent Tree Model
and its Application to Health Analytics. pages 1–19.
Kalaghatgi, P., Pfeifer, N., and Lengauer, T. 2016. Family-joining: A fast distance-based method for
constructing generally labeled trees. Molecular Biology and Evolution, 10(33): 2720–2734.
Kruskal, J. B. 1956. On the Shortest Spanning Subtree of a Graph and the Traveling Salesman Problem.
Proceedings of the American Mathematical Society, 7(1): 48–50.
Peters, T. 2002. Timsort - Python. https://svn.python.org/projects/python/trunk/Objects/listsort.txt. See
also https://en.wikipedia.org/wiki/Timsort.
Ravi, R. and Singh, M. 2006. Delegate and conquer: An LP-based approximation algorithm for minimum degree MSTs. Proceedings of the 33rd International Colloquium on Automata, Languages and Programming, pages 169–180.
Saitou, N. and Nei, M. 1987. The neighbor-joining method: a new method for reconstructing phylogenetic
trees. Molecular biology and evolution, 4(4): 406–425.
Tarjan, R. E. 1975. Efficiency of a Good But Not Linear Set Union Algorithm. Journal of the ACM , 22(2):
215–225.

16

