Bounds for phylogenetic network space metrics

Phylogenetic networks are a generalization of phylogenetic trees that allow for representation of reticulate evolution. Recently, a space of unrooted phylogenetic networks was introduced, where such a network is a connected graph in which every vertex has degree 1 or 3 and whose leaf-set is a fixed set X of taxa. This space, denoted \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {N}(X)$$\end{document}N(X), is defined in terms of two operations on networks—the nearest neighbor interchange and triangle operations—which can be used to transform any network with leaf set X into any other network with that leaf set. In particular, it gives rise to a metric d on \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\mathcal {N}}(X)$$\end{document}N(X) which is given by the smallest number of operations required to transform one network in \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\mathcal {N}}(X)$$\end{document}N(X) into another in \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\mathcal {N}}(X)$$\end{document}N(X). The metric generalizes the well-known NNI-metric on phylogenetic trees which has been intensively studied in the literature. In this paper, we derive a bound for the metric d as well as a related metric \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$d_{N\!N\!I}$$\end{document}dNNI which arises when restricting d to the subset of \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {N}(X)$$\end{document}N(X) consisting of all networks with \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$2(|X|-1+i)$$\end{document}2(|X|-1+i) vertices, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$i \ge 1$$\end{document}i≥1. We also introduce two new metrics on networks—the SPR and TBR metrics—which generalize the metrics on phylogenetic trees with the same name and give bounds for these new metrics. We expect our results to eventually have applications to the development and understanding of network search algorithms.


Introduction
Phylogenetic networks are a generalization of phylogenetic trees that are used to represent either non-tree-like evolutionary histories arising in organisms such as plants and bacteria, or uncertainty in evolutionary histories [10].Here we are interested in unrooted binary phylogenetic networks on a finite set X of taxa, or networks for short.These are connected graphs in which every vertex has degree 1 or 3 and whose leaf-set is X [6].An example of such a network is presented in Figure 1(i).Note that if a network is a tree (i.e. it has no cycles), then it is also known as a phylogenetic tree.Networks can be generated from biological data using software such as T-REX [12] and have been used, for example, to study the origin of genomes in eukaryotes [14].
Recently, it has been shown that it is possible to transform any network on a set X into any other network on the same set using a finite sequence of two types of operations [9].These operations are pictured in Figure 1(ii) and (iii), and are called nearest neighbor interchange (NNI) and triangle operations, respectively.Note that the NNI operation generalizes the operation with the same name which is used to compare phylogenetic trees [15].In light of this result, as observed in [9], a space N (X) of phylogenetic networks on X may be defined as follows.It is the graph with vertex set consisting of all networks on X, and edges corresponding to pairs of networks which differ by either one NNI operation or one triangle operation.Since we can transform any network in N (X) into any other network in N (X) using a finite sequence of NNI and triangle operations, it follows that the space N (X) is connected.
The space N (X) generalizes tree-space [3], the graph with vertex set consisting of all phylogenetic trees on X with edges corresponding to pairs of trees which differ by one NNI operation.Indeed, it actually contains tree-space (on X) as a subspace as we shall now explain.For i ≥ 0, we let N i (X) denote the set of all networks on X with 2(|X| − 1 + i) vertices, which we call the i'th tier.A tier 3 example is shown in Figure 1(i).Clearly the space N (X) is the disjoint union of the set of tiers N i (X) taken over i ≥ 0.Moreover, tier N 0 (X) is precisely the set of phylogenetic trees on X.Each tier N i (X) is a connected subgraph of N (X), where the edges correspond only to NNI operations [9], so that tree-space is a subspace of N (X).
Tree-space is equipped with the NNI metric d NNI , which for any two trees T and T contained in it is defined to be the minimum number of NNI operations required to transform T into T .The NNI metric has been intensively studied in the literature (see e.g.[4]), and its properties have important consequences for tree search algorithms.One such property is the diameter of tree space, where the diameter ∆(D) of a metric D on a set Y is its maximum value taken over all pairs of elements in Y .In [11] it is shown that, for = |X| ≥ 3, the diameter of d NNI satisfies The second bound improved on an O( 2 ) upper bound given by Robinson in [15].
Network spaces are equipped with metrics which naturally generalize the NNImetric on trees.In particular, for N, N ∈ N i (X) (or, more generally, N, N ∈ N (X)), we define the distance d NNI (N, N ) (the distance d N (X) (N, N )) to be the minimal number of NNI operations (respectively, NNI and triangle operations) to transform N into N .In this paper, we focus on giving bounds on the diameter of d NNI of tier N i (X), and upper bounds for d N (X) (N, N ) for any N, N ∈ N (X).Note that d NNI is bounded on N i (X) (since |N i (X)| is finite), whereas d N (X) can become arbitrarily large on N (X).Hence it only makes sense to consider diameter bounds for the metric d NNI on N i (X).As with tree-space, we expect that our results could eventually prove useful for network construction algorithms.
We now summarize the contents of this paper.After presenting some preliminaries in the next section, in Section 3 we begin by introducing a family of phylogenetic networks that we call "echidna" networks.We then exploit properties of these networks in Section 4, together with results on graph grammars [16], to give a lower bound for the diameter of the metric d NNI on N i (X) (see Theorem 4.3).An upper bound for the same diameter is then derived in Section 5 (see Theorem 5.6).To derive this bound, we exploit properties of Hamiltonian paths in the graph that arises from a network by removing its leaves and their adjacent edges.Using our upper bound on d NNI , we also derive an upper bound for d N (X) (N, N ) for any N, N ∈ N (X) (see Corollary 5.7).
In Section 6, we define SPR and TBR operations on networks.These operations generalize the NNI operation, as well as the well-known subtree prune and regraft (SPR) and tree bisection and reconnection (TBR) operations on trees (cf.[1]).The SPR and TBR operations allow parts of a network to be chopped off and reconnected somewhere onto the resulting network, in contrast to the NNI and triangle operations which are local in nature.In Section 7, we derive bounds for the diameter of the SPR and TBR metrics on the set on N i (X).We conclude in Section 8 with a discussion of some possible future directions.

Preliminaries
For us, graphs contain no parallel edges (edges with the same pair of end vertices), and no loops (edges with one vertex as both end vertices).This means that edges are uniquely determined by a pair of vertices {v, w} with v = w.
Suppose throughout that X is a finite set with |X| ≥ 3. A phylogenetic network on leaf-set X (or a network (on X), for short) is a connected graph in which every vertex has degree 3 or degree 1, and in which the vertices of degree 1 are labelled by the elements of X (e.g. Figure 1(i)).This means that a phylogenetic network is essentially a cubic graph (a graph in which every vertex has degree 3) with leaves attached.It also means that phylogenetic networks for us are unrooted, so that edges have no implicit direction.An NNI operation on adjacent degree three vertices, changing a path The triangle operation that shifts between tiers N i (x) and N i+1 (X), i ≥ 0.
Write V (N ) for the set of vertices in N and E(N ) for the set of edges of N .We will reserve n for the number of vertices in the network, n := |V (N )|.
The concept of the tier of a network on X will be important for this paper, and has been defined in Section 1 (following [9]).It is also known as the reticulation number of a network, because it is the number of edges one must remove from it for it to become a phylogenetic tree on X (Lemma 5.1).
A cut-edge, or bridge, of a network is an edge whose removal disconnects the graph.A cut-edge is trivial if one of the connected components induced by the cut-edge is a vertex and non-trivial otherwise.A simple network is one whose cut-edges are all trivial (so note, for instance, that trees on more than two leaves are not simple networks).A blob in a network is a maximal subgraph that has no cut-edge, and that is not a vertex [6].
There are several numbers associated with a network that will be widely used in this paper.The first, n, has already been mentioned: n = |V (N )|.Others are the size of the leaf-set, := |X|, and the tier of the network, which we will usually denote i.These three variables are related by the following equation, as stated in the Introduction: In this paper we will consider networks that we call pseudo-Hamiltonian: networks that contain a cycle that passes through every non-leaf vertex.Note that every pseudo-Hamiltonian network is simple, but not vice versa.One can construct simple graphs that are not pseudo-Hamiltonian, by for instance taking a cubic graph that is not Hamiltonian, and adding some leaves to it.
The nearest-neighbour interchange (NNI) is a local operation, initially defined for phylogenetic trees, that is important for moving around tree-space in search algorithms.Such algorithms are vital for estimating phylogenetic trees using likelihood or parsimony methods.The NNI operation has also been defined as follows for phylogenetic networks [9], since it is in a sense an operation on a pair of adjacent degree 3 vertices in a graph (see Figure 1(ii)).Definition 2.1 (NNI).Let v 1 , v 2 , v 3 , v 4 be a path in a network in which neither {v 1 , v 3 } nor {v 2 , v 4 } is an edge.An NNI operation on this path replaces it with the path v This replacement of a path has the effect of retaining the central edge {v 2 , v 3 }, while replacing edge {v 1 , v 2 } with the new edge {v 1 , v 3 } and edge {v 3 , v 4 } with the new edge {v 2 , v 4 }.
We now briefly digress beyond a fixed tier and consider the wider network space N (X).The triangle operation introduced in [9], allows movement between tiers by inserting a 3-cycle at any degree-3 vertex ("blow-up"), or collapsing a 3-cycle into a degree-3 vertex ("collapse").See Figure 1(iii).

Proposition 2.2 ([9]
).The space of networks N (X) is connected by NNI operations together with triangle operations.
Because the space N (X) is connected, the distance d N (X) is well-defined, and indeed is a metric (as is the NNI distance on tier i networks) [9,Theorem 5].As it turns out, a canonical extension of the notion of the subtree prune and regraft (SPR) and tree-bisect and regraft (TBR) operations for trees to networks (see Definitions 6.1 and 6.2 for precise details) allows us to establish the companion result for Proposition 2.2.
Corollary 2.3.The space of networks N (X) is connected by SPR operations together with triangle operations, and by TBR operations together with triangle operations.
Proof.Each SPR or TBR operation can be performed by a series of NNI operations (this is easy to check and is noted in Lemma 6.3), so the result follows immediately from Proposition 2.2.
Finally for this preliminary section, we reiterate that this paper is focussed on movements within a single tier.The remarks about wider movement around the space N (X) in Proposition 2.2 and Corollary 2.3 are included for context.Write S k for the symmetric group on the set {1, . . ., k}, for k ≥ 1.For the sake of extremal cases, we set S 0 to be trivial group consisting of the empty map from ∅ to itself.Similarly, we adopt the convention that 0! = 1.

Echidna graphs
The first main result of this paper, provided in Section 4, is a lower bound on the diameter of the space N i (X) of tier i phylogenetic networks under NNI operations.To obtain this bound, we will need a lower bound on the number of phylogenetic networks in tier i.That lower bound is established in this section (Corollary 3.4), by counting the number of distinct networks in a subset of N i (X).This subset is the set of echidna graphs, which we will define shortly.Echidna graphs are useful for this purpose because they can be counted through a bijection with a set of sequences S(p, q), defined as follows.
For integers p ≥ 1 and q ≥ 0, define S(p, q) to be the set of sequences of length p + q whose entries are the symbols {a 1 , . . ., a p } and q copies of 0, and that begin and end with a 1 and a p respectively.Denote the k-th entry of a sequence S ∈ S(p, q) by S For ≥ 3 and i ≥ 1, we use a sequence S ∈ S( , i − 1) and a permutation π ∈ S i−1 (if i > 1), to define a tier i network G(S, π) with leaves labelled {1, . . ., } as follows.
Draw a circle and create + i − 1 degree 2 vertices labelled clockwise by the sequence elements . Each vertex is thus labelled a j for some j = 1, . . ., or 0. To each of the vertices for which S[k] = 0, attach a leaf with label k.Next, subdivide the edge {S [1], S[ + i − 1]} by i − 1 degree 2 vertices reading anticlockwise from S [1] to S[ + i − 1].Referring to the resulting graph also as C, draw i − 1 chords, that is, edges from the degree 2 vertices along the top of C (those labelled 0) to the degree 2 vertices along the bottom of C according to the permutation π (using implied numbering from their positions in the sequence).Denote this graph G(S, π).An example with π = id is shown in Figure 2. We call graphs constructed in this way echidna graphs, and for a given number of leaves and i ≥ 1, denote the set of such graphs Note that elements of G( , i − 1) are tier i phylogenetic networks, and are also pseudo-Hamiltonian graphs, as defined in Section 2.
In what follows, we will restrict our attention to echidna graphs in which the permutation in S i−1 is the identity map π 0 .We will show that different sequences in S( , i − 1) generate non-isomorphic graphs, and begin by noting some properties of echidna graphs generated from different sequences.Lemma 3.1 states that if graphs are obtained from two sequences that are the same up to the k-th entry, then distances from the leaf labelled 1 to any of the vertices labelled by the first k − 1 sequence entries are the same in both graphs.This follows from the construction, using the identity permutation π 0 .The lemma also formalises the point that if the last point of agreement in the two sequences is a zero, then paths from leaf 1 to beyond that point must go through one of two vertices (the one that's the last point of agreement, and the other end of the chord it connects to), and focuses this property on a particular vertex in the k-th position of one of the sequences (α) that we will use for later argument.
Suppose S = S and let k be the first position at which they differ, that is, k ∈ {1, . . ., Suppose, without loss of generality, that S[k] = 0 (noting that at least one of S[k] and S [k] must be non-zero), so that S[k] = a α for some α = 2, . . ., − 1.Then, but not labelled S [k − 2] or S [k], by x.Then any path from leaf 1 to leaf α in G must go through at least one of S [k − 1] or x.
Proof.Clear from the construction of G and G .Now we consider the same set-up, but with the assumption that the distances between two specific leaves in the two graphs are equal.The two leaves are those labelled 1, and labelled α (the leaf corresponding to the first point that the sequences differ).Lemma 3.2.Continuing with the notation introduced in Lemma 3.1, assume that = 0 is the last zero entry in S (and therefore S ), and a α is the second last entry in S .That is, S Proof.Firstly, we rule out the case that a α is the first entry in S after a 1 , namely the case , and so d G (1, α) = 3 by the assumption of the Lemma.But by construction of the echidna graphs, the only way two leaves can be 3 apart is if their corresponding terms are adjacent in the graph's defining sequence, and this forces a α to also be the second entry of S , a contradiction (since S and S differ at the k-th position).Now suppose k > 2 and consider minimal paths from 1 to α. Suppose, by way of contradiction to (A), that S[k − 1] and S [k − 1] = 0 (the sequences agree before the k-th position).The vertex S[k − 1] has degree 3, with two of its neighbouring vertices being S[k −2] and S[k] = a α (noting k > 2), and the third, x, being a vertex at the bottom of the graph connected by a chord, c.By Lemma 3.1(ii), a minimal path from 1 to α must go through S[k − 1] or x, and so either since the distance from x to α is 3.This can be seen because there cetainly is a path of length 3 from x to α (up chord c to S[k − 1], then to S[k] = a α , and then to leaf α), and in general any path from x to α must go up a chord, must go from S[k ± 1] to S[k], and must go from S[k] to α: at least 3 steps.
, both of which are ruled out by assumptions, so therefore Any path of length 3 from x to α in G that goes up the chord c would similarly force a α = S [k] or S [k − 2], both not possible.So the path of length 3 from x to α in G does not go up c.It also cannot go towards the preceding chord since that is further from α. Therefore it goes towards the leaf labelled , from x.If there was another chord in G coming after c, then any path from x to α going up that chord would have distance at least 4: the path along the bottom from x to the new chord; the chord; the path along the top from the top of the chord to a α ; and the edge to the leaf α itself.This is a contradiction.
If there is no chord coming after c in G , then we are in the situation of (B): c is the last chord, in the (k − 1)-th position (so that S [k − 1] is the last zero in S and S ), and the position of α in G must be adjacent to the final leaf, .This situation is illustrated in Figure 3.We are now able to prove our main result about echidna graphs: that distinct (non-isomorphic) echidna graphs are generated by distinct sequences.Proposition 3.3.Fix π 0 = id ∈ S i−1 and write G = G(S, π 0 ) and G = G(S , π 0 ).
Proof.Suppose k is the first position for which S[k] = S [k].Then this position is non-zero in at least one of S and S , and so without loss of generality suppose that If (B), note that α in G is not adjacent to the final leaf , since if it were then S = S (a α is the first point at which they differ).However α in G is adjacent to , meaning d G (α, ) = 3 < d G (α, ), and so the graphs are not isomorphic.
Corollary 3.4.The number of tier i phylogenetic networks on X, with |X| = and i ≥ 1, is Proof.The number of distinct echidna graphs with π = id is at least the number of sequences in S( , i − 1), namely ( +i−3)! (i−1)!, and the set of such echidna graphs is a subset of the set of tier i phylogenetic networks.
Remark 3.5.It would be good to be able to remove the (i − 1)! from the denominator of the bound in Corollary 3.4.One way to achieve this might be to count echidna networks for general π ∈ S i−1 , but it seems that this is not trivial.

A lower bound on the NNI diameter.
In this section we provide a lower bound on the maximum distance between two tier i phylogenetic networks under NNI operations (Theorem 4.3).Our strategy follows that of Li, Tromp and Zhang [11], who construct bounds for a similar NNI diameter on tree-space.The strategy involves first bounding the number of networks in a ball of given radius around a network (Proposition 4.1), then using upper and lower bounds on the size of a factorial (Lemma 4.2).For the former of these, we follow [11] in using the concept of a "graph grammar", from Sleator, Tarjan and Thurston [16].
Proposition 4.1.The number of networks in N i (X) reachable in m or fewer NNI operations from any given network in N i (X) is at most 6 2( +i−1)+10m .
Proof.Define a graph grammar by the three "productions" shown in Figure 4 (to use the language of Sleator et al [16]).There is one "triplet" production (see Fig. 4(i)) and two "quartet" productions (see Figs. 4 (ii) and (iii)) .For each vertex of degree 3, label half-edges in arbitrarily by 1,2,3.Any NNI operation on a quartet in N involves at most five of the productions in Figure 4: up to two rotations of labels for each vertex, performed by the triplet production, to align the labels with the quartet productions, plus one of the quartet productions.Thus, a sequence of m NNI operations becomes a sequence of at most 5m productions in the graph grammar.Now, applying Theorem 2.3 of Sleator et al [16], the number of networks in N i (X) reachable in m or fewer steps from any network in N i (X) is (c + 1) n+5rm , where c = 5 (the number of vertices on the left side of the grammar), r = 2 (the largest number of vertices on the right side of any one production), and n = 2( + i − 1) (the number of vertices in the network).This completes the proof.
Note that the leaf labels in a phylogenetic network are "tags" in the sense of [16], and by [16,Remark 3.4], this does not change the formula in [16, Theorem 2.3] for (leaf-labelled) phylogenetic networks.
We will exploit Stirling's well-known formula giving bounds on m!, stated below.Theorem 4.3.The diameter ∆ i of the set of tier i phylogenetic networks, i ≥ 1, is bounded below by Proof.By Proposition 4.1, the number of networks reachable in ∆ i operations is at most 6 n+10∆ i .But since this is the diameter, this is all networks.Thus from Corollary 3.4, we have (1) Using Lemma 4.2, with m = n 2 − 2 for the numerator and m = i − 1 for the denominator of Equation (1), this gives: Taking logs base 6 and reorganising gives as required.

An upper bound on the NNI diameter
In this section we establish an upper bound on the NNI diameter of the space of phylogenetic networks, by providing a schematic NNI path between any two networks.The maximal length of this path is then an upper bound for the diameter of the space (Theorem 5.6).
The path we construct is as follows: first convert N into a simple network, and then into a pseudo-Hamiltonian network (defined in Section 2).Upper bounds for the number of steps in these conversions are given in Lemmas 5.3 and 5.4 respectively.We then show how to convert any pseudo-Hamiltonian network into any other in a bounded number of steps (Lemma 5.5).
Finally we remark in Corollary 5.7 that this result can be used to bound the distance between an arbitrary pair of networks in possibly different tiers.
We begin by deriving an upper bound on the number of non-trivial cut-edges for a network in tier i.
Given a connected graph G with vertex set V and edge set E, we define r(G) = |E| − |V | + 1.Note that r(G) is clearly the number of edges that need to be removed from G in order to obtain a tree that is a spanning tree for G.For a network N ∈ N (X), r(N ) is known as the reticulation number of N .
Proof.We show first that for any network N ∈ N i (X) we have |E(N )| = 2 − 3 + 3i.Suppose N ∈ N i (X).Then by [9, Theorem 3], we can obtain N by first taking some phylogenetic tree (i.e. a network in tier 0) which has 2 − 3 edges, then performing i triangle operations (which adds 3i edges) to obtain a network in N i (X), and then performing some sequence of NNI operations to get N (which does not change the number of edges).Hence |E(N )| = 2 − 3 + 3i, as required.
Proposition 5.2.Let N ∈ N i (X) some i ≥ 0, with n vertices.The number of non-trivial cut-edges in N is at most + i − 3.
Proof.Without loss of generality, we may assume that i ≥ 1 as otherwise N is a phylogenetic tree on X and that the result clearly holds.We consider the phylogenetic tree T on X that is obtained by shrinking each blob in N down to a vertex.Note that the number of non-trivial cut-edges in N is clearly at most the number of edges in T minus .Now, it follows by [9, Lemma 6], that by shrinking a blob B of N down to a vertex, we lose at least r(B) vertices.But r(N ) is the sum of the values r(B) taken over all blobs B in N .Hence, since r(N ) = i by Lemma 5.1 and |V (N )| = 2( + i − 1), the tree T has at most 2 + i − 2 vertices, and so it has at most 2 + i − 3 edges.The proposition now follows immediately.
Lemma 5.3.Suppose N ∈ N i (X) and i ≥ 1.We can convert N into a simple network by performing at most + i − 3 NNI operations on N .
Proof.Without loss of generality we may assume that N is not simple as otherwise the lemma clearly holds.Since i > 0, N contains at least one blob.Let e be a non-trivial cut-edge of N and let a, b ∈ V (N ) such that e = {a, b}.Furthermore, let u ∈ V (N ) such that u is adjacent with a and let w ∈ V (N ) − {a} such that w is adjacent with b.Finally, let C denote the connected component of N containing a, obtained by deleting the edge e.For the convenience of the reader, we depict in Figure 5 the case that C contains a cycle which shares a vertex with e and that the other vertex of e is not contained in a cycle of N .Since e is a cut-edge of N we can perform an NNI operation on the path u, a, b, w to obtain a new network N .Since e has been incorporated into C in N and no new cut-edge has been created by that operation, it follows that N has one cut-edge less than N .Consequently, by performing at most the number of non-trivial cut-edges NNI operations, we can convert N into a simple network.The statement follows, by Proposition 5.2.
We now give an algorithm to convert N into a pseudo-Hamiltonian network.
Lemma 5.4.Suppose N ∈ N i (X) is simple, with i ≥ 1.We can convert N into a pseudo-Hamiltonian network by performing at most n NNI operations on N .
Proof.Suppose N is not pseudo-Hamiltonian.Since N is simple it must contain a blob B, and every cut-edge of N is trivial.Choose a maximal length cycle C in B.
Choose a non-leaf vertex v that is not in C, but is adjacent to a vertex w ∈ V (C).Since w has degree 3 there must exist a vertex w 1 ∈ V (C) that is adjacent with w.Note that w 1 and v can not be adjacent, since if they were, they would be in a cycle that is longer than C, violating maximality (the path w 1 to w could be extended by going through v).Since v is not a leaf of N , we may choose another vertex v 1 ∈ V (N ) − w that is adjacent to v. Again, since w has degree 3, and is contained in a cycle and adjacent to v (outside the cycle), the edge {w, v 1 } also is not contained in N .Hence, we may apply an NNI operation on the path w 1 , w, v, v 1 to obtain a new network N .Note that N is still a simple network, but the cycle C has been extended to create a new cycle C with one more vertex, namely v.To see that N is still simple, let v 2 ∈ V (N ) − {w, v 1 } be the "other" vertex adjacent to v in N .Consider the edges {v, v 1 } and {v, v 2 } in N .Because N simple, at most one of v and v 2 is a leaf, and other is (or both are) part of a path w, v, v i , . . .that begins and ends in a vertex in the cycle C.If one of v 1 , v 2 was a leaf attached to v in N , it remains a leaf in N , but is now attached to the cycle C .For v i not a leaf, it is part of a path back to C in N , and remains part of a path back to C in N (a path that is now one vertex shorter).
It follows that a sequence of NNI operations can be performed, each increasing the length of a maximal length cycle in the network by one vertex.This process ends, since the number of vertices is finite, and it ends with a pseudo-Hamiltonian network.The number of NNI operations taken is at most the number of vertices in N .
In our final lemma before the main theorem, we bound the distance between any two pseudo-Hamiltonian networks.Proof.Fix a pseudo-Hamiltonian cycle for each network.Both these cycles are of the same length, namely n − = + 2(i − 1), and both have the same number, , of vertices adjacent to leaves.The leaves of each network are labelled 1 to ; number the adjacent vertex of each leaf by the same label.These vertices are on the pseudo-Hamiltonian cycle.Now, for each network, and for each non-leaf edge that is not on the pseudo-Hamiltonian cycle (each chord ), number its end vertices by pairs { +1, +2}, . . ., { +2i−3, +2i−2}.This gives every vertex in each network a label ( leaves, leaf-adjacent vertices, and 2(i − 1) vertices contained in chords, for a total of 2( + i − 1)).
For any two adjacent vertices v 2 , v 3 on a pseudo-Hamiltonian cycle, performing an NNI operation on the length three sub-path v 1 , v 2 , v 3 , v 4 has the effect of swapping the middle two adjacent vertices to give the sub-path v 1 , v 3 , v 2 , v 4 .Consequently, the arrangement of the vertices labelled 1, . . ., + 2(i − 1) on the pseudo-Hamiltonian cycles can be sorted between the two networks by NNI operations in the number of swaps of adjacent vertices in the cycle.This is bounded by the diameter of the symmetric group on + 2(i − 1), which is We can now give an upper bound for the diameter of N i (X).
Theorem 5.6.The diameter Proof.By Lemmas 5.2 and 5.3, any network in tier i ≥ 1 can be transformed into a pseudo-Hamiltonian network in at most n 2 − 1 + n steps: n 2 − 1 = + i − 3 to become simple and n to become pseudo-Hamiltonian.So given any two networks in N i (X), they can be both made pseudo-Hamiltonian in a total of 3n − 2 steps, and, by Lemma 5.5, one can be transformed the other in steps.
Note that the same bound for i = 0 follows immediately from [11] (where the bound is better than in this statement, being essentially log ).
We can use Theorem 5.6 to find an upper bound for the distance between any pair of networks in N (X), irrespective of tier.
Corollary 5.7.Let N, N ∈ N (X), with N ∈ N i (X) and N ∈ N j (X).Suppose without loss of generality that 0 ≤ i ≤ j.
Proof.By performing j − i triangle operations starting with N we can create a network N in tier j.The distance from N to N is bounded above by the diameter bound ∆ j given in Theorem 5.6 (in which n is the number of vertices in tier j, namely n = 2( + j − 1)).Hence, the distance from N to N is at most j − i + ∆ j , and as required.

SPR and TBR operations
In this section, we define "subtree prune and regraft" (SPR) and "tree bisection and regraft" (TBR) operations on network space N i (X), i ≥ 1.We extend the results of the previous sections on NNI operations to these operations on network space in Section 7. To state these definitions for some network N ∈ N (X), let v, w ∈ V (N ) such that v is of degree 3. Assume that e = {v, w} is an edge in N , but that {v 1 , v 2 } is not an edge in N , where v 1 , v 2 are the vertices other than w incident to v in N .Definition 6.1 (SPR operation).An SPR operation on e first removes e from N and then suppresses v (the degree of v is now 2).Next, it attaches a new edge {w, x} to w, where x is a vertex subdividing an edge e of N not incident to w.In case e is a cut-edge of N then we also require that e is contained in the connected component not containing w. Definition 6.2 (TBR operation).Assume that w is such that the degree of w is also 3 and that {w 1 , w 2 } is not an edge in N where w 1 , w 2 ∈ V (N ) − {v} are the other two vertices in N incident with w.A TBR operation on e = {v, w} deletes the edge, suppressing the resulting degree 2 vertices v and w, and adds a new edge on N between a subdivision vertex of an edge e and a subdivision vertex of a further edge e 2 of N .In case e is again a cut-edge of N , we also require that e 1 and e 2 are contained in distinct connected components.
It is straightforward to check that in network space, each NNI operation is also an SPR operation, and each SPR operation is also a TBR operation, so we state the following without proof.Lemma 6.3.NNI ⊆ SPR ⊆ TBR.
We will write d Θ for the distance under the operation Θ, for Θ ∈ {NNI, SPR, TBR}.Note that these are distances within a tier, since each operation Θ is an operation that remains in a fixed tier.We have already noted in Section 2 that d NNI is a metric and, in view of the last lemma, it is straight-forward to check that the same also holds for d SPR and d TBR .
In fact any TBR operation can be done by just two SPR operations, giving the following relationship among corresponding distances: Lemma 6.4.The TBR distance d TBR (N, N ) ≤ 2d SPR (N, N ), the SPR distance, for networks N, N ∈ N i (X).
Proof.Each TBR operation on an edge e of a network N ∈ N (X) can be performed by a pair of SPR operations where in the first SPR operation the role of v is played by one of the two vertices incident with e and, in the second, that role is played by the other vertex incident with e.

7.
Upper and lower bounds on the SPR and TBR diameters of N i (X) We write N Θ i (X) for the space of networks in tier i under the operation Θ ∈ {NNI, SPR, TBR}, and write ∆ Θ i for the diameter of N Θ i (X).The number of SPR operations from any given network N in tier i ≥ 0 can be given an upper bound as follows.
First, there is the number of edges one may choose for the operation.The number of edges is half the total degree, which is 3n − 2 (each vertex has degree 3 except the leaves, which have degree 1).Note, 3n − 2 = 2(n + i − 1), and so the number of edges is n + i − 1.
Each edge e has two end vertices that may be chosen to be detached, and then one may regraft e on to any edge except e itself and the edges still incident to it: n + i − 4 choices.
Thus there are at most 2(n + i − 1)(n + i − 4) networks reachable from any network in N i (X) by applying one SPR operation.Setting d = ∆ SPR i , following the previous logic of Section 4, we have that the number of networks in N i (X) is at most (2(n + i − 1)(n + i − 4)) d , and so we have using the calculation in the proof of Theorem 4.3.Taking natural logs: Therefore, This lower bound on the diameter ∆ SPR i gives us one for the TBR diameter, noting Lemma 6.4: Proposition 7.1.
To obtain upper bounds for ∆ SPR i and ∆ TBR i , we can similarly follow our approach from the NNI case.
To move from a phylogenetic network N ∈ N i (X) to another network N ∈ N i (X), first, convert the phylogenetic networks into pseudo-Hamiltonian forms, N 1 and N 1 .This takes at most 2n moves for each network, since that's how many NNI moves it takes (Lemmas 5.3 and 5.4).Combining Lemmas 5.5 and 6.3, at most n 2 SPR moves are needed to transform N 1 to N 1 .This gives an upper bound for the SPR diameter of Since each SPR move is also a TBR move (Lemma 6.3), the number of TBR moves between any two networks is at most the maximum number of SPR moved.That is, d TBR ≤ d SPR , which gives an upper bound on ∆ TBR i .These upper bounds are summarized as follows: Proposition 7.2.
Both upper bounds in Proposition 7.2 could be improved by an improvement on the upper bound for the number of SPR moves required to move between two pseudo-Hamiltonian networks.Whether that bound of n 2 can be improved is a question that may be of independent interest.

Discussion
In this paper, we have presented upper and lower bounds for the diameter of the metric d Θ on N Θ i (X), Θ ∈ {NNI, SPR, TBR}.It would be interesting to know if these bounds can be improved upon and how close they are to being sharp.We suspect that the lower bound given in Theorem 4.3 could be improved by finding a larger lower bound for the number of networks in N i (X) than the one given in Corollary 3.4, but have not been able to show this.It would also be of interest to obtain a deeper understanding of the relationship between the structure of the space N (X) under d Θ and the subspace obtained by restricting d Θ to the tier N Θ i (X), i ≥ 0. For example, it is clear that N Θ i (X) is not an isometric subspace of N (X) under the metric d Θ for i ≥ 1, by virtue of the following example.Take a network N in tier i, and use the triangle operation to blow up a vertex v, giving a new network N in tier i + 1.Now repeat this operation on N but this time use the triangle operation on a different vertex w = v, to get a different network N in tier i + 1.The distance between N and N in N (X) is 2, through two judicious uses of the triangle operation.But the distance between them staying within tier i + 1 is strictly greater than 2, regardless of which operation of NNI, SPR or TBR is used.
In this paper we have considered unrooted networks.However, it would be very interesting to see how our results could be extended to rooted networks.Some results concerning spaces of rooted networks are presented in [13] and [18].However, it is still necessary to define operation-based metrics on these spaces, and previous work on spaces of level-1 rooted networks [8] suggests that this could be quite technical.Moreover, to find diameter bounds on the resulting space of rooted network metrics such as the one given in Theorem 4.3, it may be necessary either to introduce a new approach for dealing with graph grammars arising from directed graphs (which are not considered in [16]), or to avoid this method of proof completely.
There are also some interesting computational questions concerning the metrics d Θ .For example, what is the computational complexity of computing d Θ ?Note that the NNI, SPR and TBR distance are all NP-complete to compute (cf.[4,7,1]).In light of this fact, it is likely that the metric d Θ is also NP-complete to compute.One way to show this could be to prove that N Θ 0 (X) (i.e.tree-space) is an isometric subgraph of N Θ (X) under d Θ , which is a special case of the problem mentioned above.
In this paper we have considered discrete spaces of networks.However, it would be interesting to define and study continuous variants of these spaces.Continuous treespaces have been defined and studied [3], and arise since real-valued edge-lengths are often assigned to phylogenetic trees.How should we formally define continuous spaces of networks with edge-weights and metrics on these spaces, and what are their properties?Note that recently a definition for a continuous space of unrooted networks has been proposed [5], and shown to have interesting geometric properties.

Figure 3 .
Figure 3.The situation of case B in Lemma 3.2.All chords are to the left of chord c in both graphs.

Figure 4 .
Figure 4.The graph grammar of productions that implement NNI operations.The labels are on half edges.

Figure 5 .
Figure 5. Example of an NNI operation on a cut-edge adjacent to a blob.