Rearrangement moves on rooted phylogenetic networks

Phylogenetic tree reconstruction is usually done by local search heuristics that explore the space of the possible tree topologies via simple rearrangements of their structure. Tree rearrangement heuristics have been used in combination with practically all optimization criteria in use, from maximum likelihood and parsimony to distance-based principles, and in a Bayesian context. Their basic components are rearrangement moves that specify all possible ways of generating alternative phylogenies from a given one, and whose fundamental property is to be able to transform, by repeated application, any phylogeny into any other phylogeny. Despite their long tradition in tree-based phylogenetics, very little research has gone into studying similar rearrangement operations for phylogenetic network—that is, phylogenies explicitly representing scenarios that include reticulate events such as hybridization, horizontal gene transfer, population admixture, and recombination. To fill this gap, we propose “horizontal” moves that ensure that every network of a certain complexity can be reached from any other network of the same complexity, and “vertical” moves that ensure reachability between networks of different complexities. When applied to phylogenetic trees, our horizontal moves—named rNNI and rSPR—reduce to the best-known moves on rooted phylogenetic trees, nearest-neighbor interchange and rooted subtree pruning and regrafting. Besides a number of reachability results—separating the contributions of horizontal and vertical moves—we prove that rNNI moves are local versions of rSPR moves, and provide bounds on the sizes of the rNNI neighborhoods. The paper focuses on the most biologically meaningful versions of phylogenetic networks, where edges are oriented and reticulation events clearly identified. Moreover, our rearrangement moves are robust to the fact that networks with higher complexity usually allow a better fit with the data. Our goal is to provide a solid basis for practical phylogenetic network reconstruction.

Now suppose that u and v have a common parent p but the childŝ = v of u and the childt of v are distinct vertices. Then we apply a type-(1) rNNI move (uŝ, uv, vt → ut, uv, vŝ). This is allowed because if there were anŝv path in N , this path would need to pass through p, and hence imply the existence of a directed cycle in N . Now we can apply a type-(1 * ) move (ut, uv, vŝ → uŝ, vu, vŝ), because not-v path can exist in N . The net effect of these two moves is that arc uv is reversed to vu, see Figure S2. If we are in neither of the previous cases, u and v have a common parent p and a common child c. But then it is easy to see that that N and N are isomorphic (just map u to v and viceversa), meaning that no rNNI move is needed to turn N into N .
Lemma 3. Let N be a binary rooted phylogenetic network and let N u be its underlying unrooted network. If an unrooted network N u can be obtained by applying a single NNI move to N u , then there exists a sequence of rNNI moves turning N into a network that has N u as its underlying unrooted network.
Proof. There are four ways in which the edges affected by the NNI move can be oriented in N , see the four networks to the left in Fig. 4 in the main text. In each case, there is at least one move that satisfies conditions 1 and 2 of Def. 1 (the degree conditions). Hence, there exists a (possibly cycle-creating) rNNI move turning N into N such that N has N u as its underlying unrooted network. However, N may contain a directed cycle. Note that a move of type (3) cannot create a directed cycle. Moreover, if the move is of type (1 * ) or (2 * ), then it can be replaced by a move of type (1) or (2) without changing the underlying unrooted network. Hence, we only need to consider moves of types (1),(2),(3 * ) and (4). These moves can create a directed cycle in the following cases: (1) (us, uv, vt → ut, uv, vs) and there is an s-v path in N ; (2) (su, uv, tv → sv, uv, tu) and there is a u-t path in N ; (3 * ) (su, uv, vt → sv, vu, ut) and there is a nonelementary u-v path in N ; (4) (us, uv, tv → vs, uv, tu) and there is a s-t path in N .
For each of these cases, we show that an acyclic network N with the same underlying unrooted network as N can be obtained from N by applying a sequence of rNNI moves.
Case (1). (us, uv, vt → ut, uv, vs) and there is a s-v path in N , see Figure S3.
The s-v path must contain at least one internal vertex since N does not contain an arc on {s, v}. Let w be the last internal vertex on this path.
First suppose that w is a bifurcation. Then we reverse the arc wv to vw using rNNI moves. To see that this is possible, note that w is a bifurcation and v a reticulation, and that there cannot be a nonelementary w-v path in N : this path would have to go via u and would form a directed cycle in combination with the s-w path in N . Hence, reversing wv to vw is an arc flip, which by Lemma 2 can be reproduced using rNNI moves. We can then apply a type-(1) rNNI move (us, uv, vt → ut, uv, vs) and obtain an acyclic network N with the same underlying unrooted network as N . See Figure S4.  (1) when w is a bifurcation. Note that the arc leaving w that does not point at v could point at t. Now suppose that w is a reticulation. Let (s = x 0 , x 1 , x 2 , . . . , x k = w) be a longest s-w path. Let x i be the first reticulation on this path. Note that there cannot be a nonelementary x i−1 -x i path because otherwise there would be a longer s-w path. Hence, we can flip the orientation of arc x i−1 x i using rNNI moves by Lemma 2. We repeat this procedure until there is no s-w path. Then we apply type-(1) rNNI move (us, uv, vt → ut, uv, vs) and obtain an acyclic network N with the same underlying unrooted network as N . See Figure S5.
Case (2). (su, uv, tv → sv, uv, tu) and there is a u-t path in N , see Figure S6. First suppose that t is a bifurcation. Then we flip arc tv to vt using rNNI moves. To see that this is possible, assume that there were a nonelementary t-v path. This path Avoiding directed cycles in Case (1) when w is a reticulation.
would then have to enter v through u. However, since there is also a u-t path, this would imply the existence of a directed cycle in N . Hence, we can perform an arc flip on tv via rNNI moves by Lemma 2. Then we can apply a type-(3 * ) rNNI move (su, uv, vt → sv, vu, ut). This move is possible because there can be no nonelementary u-v path since v has indegree 1. We have thus obtained an acyclic network N with the same underlying unrooted network as N . See Figure S7. Now suppose that t is a reticulation. Let (u = x 0 , x 1 , x 2 , . . . , x k = t) be a longest u-t path in N . Let x i be the first reticulation on this path. Then we flip arc x i−1 x i (which is again possible since we chose a longest u-t path) using rNNI moves, and keep repeating this procedure until there are no u-t paths left. Then we apply type-(2) rNNI move (su, uv, tv → sv, uv, tu) and obtain an acyclic network N with the same underlying unrooted network as N . See Figure S8.
Avoiding directed cycles in Case (2) when t is a reticulation.
Case (3 * ). (su, uv, vt → sv, vu, ut) and there is a nonelementary u-v path in N , see Figure S9. First suppose there exists at least one nonelementary u-v path where the last internal vertex w of the path is a bifurcation. Then we flip arc wv using rNNI moves. This is possible by Lemma 2 because a nonelementary w-v path would have to pass through u and hence imply the existence of a directed cycle in N involving u and w. After that, there can be no nonelementary u-v path since v has only one incoming arc which comes from u. Therefore, we can apply the type-(3 * ) move (su, uv, vt → sv, vu, ut) and we are done. See Figure S10. Now suppose that in all nonelementary u-v paths the last internal vertex is a reticulation. Then we take a longest u-v path (u = x 0 , x 1 , x 2 , . . . , x k = v) and let x i be the first reticulation on this path. Then we flip arc x i−1 x i , which is again possible since we chose a longest u-v path. We repeat this procedure until there are no nonelementary u-v paths left. Then we can apply the type-(3 * ) move (su, uv, vt → sv, vu, ut) and we are done. See Figure S11.
Case (4). (us, uv, tv → vs, uv, tu) and there is an s-t path in N , see Figure S12. First suppose that t is a bifurcation. Then we flip arc tv using rNNI moves. As before, this is possible because a nonelementary t-v path would need to pass through u and hence imply the existence of a directed cycle in N . Then we apply a type-(1) rNNI move (us, uv, vt → ut, uv, vs). This is possible because any s-v path would have to pass through u and hence imply the existence of a directed cycle in N . See Figure S13. Now suppose that t is a reticulation. Then we take a longest s-t path (s = x 0 , x 1 , x 2 , . . . , x k = t) and let x i be the first reticulation on this path. If i = 0, i.e. if s is a reticulation, then we flip arc us, apply a type-(2) move (su, uv, tv → sv, uv, tu) and we are done. Otherwise, we flip arc x i−1 x i which is, as before, possible since we chose a longest s-t path, and we repeat the procedure until there are no s-t paths left. Then we can apply the type-(4) move (us, uv, tv → vs, uv, tu) and we are done. See Figure S14.
Avoiding directed cycles in Case (4) when t is a reticulation.
Lemma 5. For any nonempty X and r ≥ 1, there exists a flip-friendly binary rooted network on X with r reticulations.
Proof. Any network with just one reticulation is level-1, and thus, by Lemma 4, also flip-friendly. In order to prove the lemma for r ≥ 2, we proceed as follows: we introduce a special type of rooted binary networks, the laddered networks, and then we show that (1) there are laddered networks on X with any number of reticulations r ≥ 2, and (2) laddered networks are flip-friendly.
A rooted ladder is a binary rooted network that can be obtained in the following manner (see Fig. S15, left): take a directed path P = p 1 p 2 . . . p r and another directed path Q = q 1 q 2 . . . q r , both on r vertices, and add an arc from p i to q i for each i ∈ {1, . . . , r}. Then add a vertex x with children p 1 and q 1 , and a vertex y with parents p r and q r . Finally add a root ρ whose only child is x and a leaf l whose parent is y. Note that the reticulations in a rooted ladder are the vertices of the Q path, and the y vertex. Clearly, for each r ≥ 2 there exists a rooted ladder with r reticulations. A laddered network is a rooted binary network obtained by taking a rooted binary tree N , then grafting a rooted ladder on the arc between the root of N and its child; if we denote these two nodes by ρ N and c, respectively, and the root of the rooted ladder by ρ, this means replacing the arc ρ N c in N with two new arcs ρ N ρ, ρc and then adding to N the remaining vertices and arcs of the rooted ladder. See Fig. S15 (right) for an example of laddered network. We can now prove the claims on laddered networks that are necessary to conclude our proof.
Claim (1). For any nonempty X and r ≥ 2, there exists a laddered network on X with r reticulations.
Let l be any element of X, and L be the rooted ladder having r reticulations and l as its leaf. Then let N be a laddered network obtained by taking a binary rooted tree on X \ {l}, then grafting L on the branch between the root of this tree and its child. If

PLOS
5/10 X \ {l} = ∅, then let N simply be L. Thus, N is a laddered network on X with r reticulations.
Claim (2). Laddered networks are flip-friendly. Let N be a laddered network on X, and N another binary rooted network on X with the same underlying unrooted network. We show that N can be transformed into N by only using arc flips.
First observe that in the "tree part" of N all arcs will be oriented in the same way as in N . If this were not true, N would be rooted in a different degree-1 node than N , and the two networks would not be on the same set X. Therefore the only arcs appearing in N but not in N will be in its "ladder part". So consider this part of N , and let x, y, l, p 1 , . . . , p r , q 1 , . . . , q r be the vertices in N described in the definition of a rooted ladder (see Fig. S15). For notational convenience let p 0 = q 0 = x, and let p r+1 = q r+1 = y.
Consider the set W 0 = {x, p 1 , . . . , p r , q 1 , . . . , q r , y, l}. The only vertex in W 0 with a neighbor outside of W 0 is x, and every vertex in W 0 has indegree at least 1 (as W 0 does not contain the root of N ). Therefore if N contains the arc p 1 x or q 1 x, it holds that for every w ∈ W 0 there exists z ∈ W 0 such that zw is an arc in N . But this implies that N has a cycle contained in W 0 , a contradiction. Thus N can have neither of the arcs p 1 x, q 1 x, and so instead N must have arcs xp 1 , xq 1 .
We have thus shown that N contains the arcs p 0 p 1 , q 0 q 1 . We will now show by induction that for each i ∈ {1, . . . , r}, N contains the arcs p i p i+1 and q i q i+1 .
Consider the set W i = {p i , . . . , p r , q i , . . . , q r , y, l}. The only vertices in W i with a neighbor outside of W i are p i and q i . If N contains the arc p i+1 p i then, as N contains the arc p i−1 p i , N must also contain the arc p i q i . But then we have that for every w ∈ W i there exists z ∈ W i such that zw is an arc in N . This implies that N has a cycle contained in W i , a contradiction. Thus N cannot contain the arc p i+1 p i . By a symmetric argument N cannot contain the arc q i+1 q i . Thus we have that for any N and every i ∈ {0, . . . , r}, N contains the arcs p i p i+1 and q i q i+1 .
It follows that the only arcs in N that may not be in N are the p i q i for some i ∈ {1, . . . , r}. For any such arc there is no nonelementary p i -q i path in N , p i is a bifurcation and q i is a reticulation. Therefore, we can perform an arc flip on each arc in N and not in N , meaning that N can be obtained from N by a sequence of arc flips. Theorem 4. Let N and N be binary rooted networks. Then, N can be turned into N with one rNNI move if and only if N can be turned into N with one rSPR 1 move.
Proof. We first prove that every rSPR 1 move is an rNNI move (which implies the if part of the theorem). In order to do this, we consider four different cases for the position of the recipient arc x y relative to the donor arcs xz, zy (see Fig. 7 in the main text). We refer to Lemma 1 for the definitions of the rNNI types (1), (1 * ), . . . , (4).
(a) y = x, that is the recipient arc enters x. In this case the rSPR 1 move coincides with the rNNI (x x, xz, zy → x z, zx, xy), which is an rNNI of type (3 * ) with s = x , u = x, v = z, t = y.
(b) x = x, that is the recipient arc exits x. In this case the rSPR 1 move coincides with the rNNI (xy , xz, zy → zy , xz, xy), which is an rNNI of type (1) with s = y , u = x, v = z, t = y.
(c) x = y, that is the recipient arc exits y. In this case the rSPR 1 move coincides with the rNNI (xz, zy, yy → xy, yz, zy ), which is an rNNI of type (3 * ) with PLOS 6/10 s = x, u = z, v = y, t = y .
(d) y = y, that is the recipient arc enters y. In this case the rSPR 1 move coincides with the rNNI (xz, zy, x y → xy, zy, x z), which is an rNNI of type (2) with s = x, u = z, v = y, t = x .
We now proceed to prove the only if direction of the theorem. That is, if N can be turned into N with one rNNI move, then the same can be done with one rSPR 1 move. Similarly to above, we consider each possible type of rNNI in turn.
(1 * ) (us, uv, vt → ut, vu, vs), where v is a reticulation in N . Let x be the only parent of u in N , and x the parent of v other than u. Now consider the rSPR 1 move with donors xu, uv and recipient arc x v, that is [xu, uv, x v → x u, uv, xv]. The resulting network is the same as N (formally, isomorphic to N ), the network produced by the rNNI above: both networks contain the arcs x α, xβ, αβ, αs, βt, with α = v, β = u in N , and α = u, β = v in the network produced by the rSPR 1 .
(2 * ) (su, uv, tv → sv, vu, tu), where u is a bifurcation in N . Let y be the only child of v in N , and y the child of u other than v. Now consider the rSPR 1 move with donors uv, vy and recipient arc uy , that is [uv, vy, uy → uv, vy , uy]. The resulting network is the same as N (formally, isomorphic to N ), the network produced by the rNNI above: both networks contain the arcs sα, tβ, αβ, αy, βy , with α = v, β = u in N , and α = u, β = v in the network produced by the rSPR 1 .
(3) (su, uv, vt → sv, uv, ut), where u is a reticulation and v a bifurcation in N . Let x be the parent of u other than s in N , and y the child of v other than t. Now consider the rSPR 1 move with donors uv, vy and recipient arc x u, that is [uv, vy, x u → x v, vu, uy]. The resulting network is the same as N (formally, isomorphic to N ), the network produced by the rNNI above: both networks contain the arcs x α, sβ, αβ, αt, βy, with α = u, β = v in N , and α = v, β = u in the network produced by the rSPR 1 .
(3 * ) (su, uv, vt → sv, vu, ut). This rNNI move is an rSPR 1 with donor arcs su, uv and recipient arc vt. Interestingly, it is also an rSPR 1 with donor arcs uv, vt and recipient arc su.
(4) (us, uv, tv → vs, uv, tu). Let y be the only child of v in N , and x the only parent of u. Now consider the rSPR 1 move with donors uv, vy and recipient arc x u, that is [uv, vy, x u → x v, vu, uy]. The resulting network is the same as N (formally, isomorphic to N ), the network produced by the rNNI above: both networks contain the arcs x α, tα, αβ, βs, βy, with α = u, β = v in N , and α = v, β = u in the network produced by the rSPR 1 .
Proposition 2. Let N be a binary rooted network. Within N , let e BB denote the number of arcs from a bifurcation to a bifurcation, e BR the number of arcs from a bifurcation to a reticulation, e RB the number of arcs from a reticulation to a bifurcation, and e RR the number of arcs from a reticulation to a reticulation. Then, the number of different binary rooted networks that can be obtained from N by one rNNI move is at most 2(e BB + e RR ) + 3e BR + 4e RB .
Proof. Every rNNI move applied to N must be around some arc uv in N , where both u and v are internal vertices (that is, neither the root or a leaf). Thus, u and v are either bifurcations or reticulations. To prove the statement, we consider the four possible assignments of u and v to these categories. In the following, we show that if u and v are both bifurcations (case BB) or both reticulations (case RR), then at most 2 networks can be obtained with an rNNI move around uv (top two lines in Fig. 8 in the main text). If instead u is a bifurcation and v a reticulation (case BR), then at most 3 networks can be obtained (third line in Fig. 8). Finally, if u is a reticulation and v a bifurcation (case RB), then at most 4 networks can be reached with an rNNI move around uv (bottom line in Fig. 8). These observations allow us to obtain the upper bound of 2(e BB + e RR ) + 3e BR + 4e RB on the size of the rNNI neighborhood. In the following four paragraphs, we provide the detailed (but tedious) proofs for cases BB, RR, BR and RB.
Case BB. If both u and v are bifurcations, name the vertices adjacent to u or v, and networks N 1 and N 2 in the way described in Fig. 8 (top line), where we may have β = γ or β = δ, but no other equality between vertices (any such equality would either imply a cycle or parallel arcs). The only rNNI moves that can be applied to N are of type (1) and (3 * ), as all other rNNI types require that either u or v is a reticulation. The type-(1) move (uβ, uv, vγ → uγ, uv, vβ) and the type-(3 * ) move (αu, uv, vδ → αv, vu, uδ) result in network N 1 , whereas the type-(1) move (uβ, uv, vδ → uδ, uv, vβ) and the type-(3 * ) move (αu, uv, vγ → αv, vu, uγ) result in network N 2 . Note that if β = γ or β = δ, then some of the moves above may not be applicable. Thus at most 2 networks can be obtained with an rNNI move around uv in this case.
Case RR. If both u and v are reticulations, name the vertices adjacent to u or v, and networks N 1 and N 2 in the way described in Fig. 8 (2nd line), where we may have β = γ or α = γ, but no other equality between vertices. The only rNNI moves that can be applied to N are of type (2) and (3 * ), as all other rNNI types require that either u or v is a bifurcation. The type-(2) move (βu, uv, γv → γu, uv, βv) and the type-(3 * ) move (αu, uv, vδ → αv, vu, uδ) result in network N 1 , whereas the type-(2) move (αu, uv, γv → γu, uv, αv) and the type-(3 * ) move (βu, uv, vδ → βv, vu, uδ) result in network N 2 . Note that if β = γ or α = γ, then some of the moves above may not be applicable. Thus at most 2 networks can be obtained with an rNNI move around uv in this case.
About the size of rNNI neighborhoods.
We now give a family of networks N k , illustrated in Fig. S16, whose rNNI neighborhood has size logarithmic in the number of arcs, in contrast with the upper bound given in the Results section, which is linear in the number of arcs.
Each network N k is built by taking two copies T k 1 and T k 2 of a complete binary rooted tree with 2 k leaves. For each pair of leaves u and v, add all possible arcs from the copies of u and v in T k 1 to the copies of u and v in T k 2 . Finally, replace each arc uv in T 2 k with the arc vu, so that the resulting network is binary with a single root and a single leaf. This completes the construction of N k (see Fig. S16). For all k > 0, as the number of arcs of a complete binary subtree with 2 k leaves is 2 k+1 − 1, the number of arcs of N k is 2 × (2 k+1 − 1) + 2 × 2 k , that is 3 × 2 k+1 − 2. However, because of the extreme symmetry of this network, all arcs that lie at the same height in the network are effectively indistinguishable, implying that rNNI moves around different arcs often result in the same network. More precisely, consider two arcs uv and u v whose sources u and u are at the same distance d from the root, for d ∈ {1, . . . , 2k + 1}. It is easy to see that the set of networks that can be obtained by one rNNI move around uv is the same as the set obtained by one rNNI move around u v , or around any other arc whose source is at distance d of the root. Thus, as Prop. 2 implies that there are at most 4 networks in each of these sets, the size of the rNNI neighborhood of N k is at most 4(2k + 1). This proves that the size of the rNNI neighborhood of N k is logarithmic in its number of arcs.
Finally, in Fig. S17, we illustrate the rNNI neighborhood of the network N 3 of Fig. 9 in the main text, which consists of 12 networks. Now note that because e BB = 3, e BR = 2, Prop. 2 gives an upper bound of exactly 12, showing that this bound is tight in this case.