Nearest-Neighbor Interchange (NNI) Search
- Nearest-Neighbor Interchange (NNI) search is a method for exploring phylogenetic tree space by swapping adjacent subtrees to transform one tree into another.
- It employs parallel subroutines—including tree linearization, edge sequence merge-sorting, and leaf permutation—to approximate weighted tree distances in O(log n) time.
- Analyses of NNI-walks reveal that focusing solely on NNI moves to cover SPR neighborhoods can incur a quadratic overhead, highlighting key combinatorial challenges.
Searching arXiv for papers on nearest-neighbor interchange search and related phylogenetic tree search. I’m checking whether the arXiv search interface is available in this environment. Nearest-Neighbor Interchange (NNI) search denotes the exploration of phylogenetic tree space by sequences of local rearrangements in which two adjacent subtrees are swapped across an operating edge. In the literature represented by "Efficient Parallel Computation of Nearest Neighbor Interchange Distances" (Gast et al., 2012) and "Walks on SPR Neighborhoods" (Caceres et al., 2011), NNI search appears in two closely related forms: as the computation of an NNI sequence that transforms one weighted phylogeny into another, and as an NNI walk that traverses a prescribed neighborhood of trees. The topic therefore spans distance measures, approximation algorithms, parallel tree transformation, and the combinatorics of local-search trajectories.
1. Formal setting and elementary operations
Let be an unrooted binary phylogenetic tree on leaf set . An internal edge of has four incident subtrees whose leaf-sets partition as . A single nearest-neighbor-interchange (NNI) move at replaces the split by one of the two alternative splits, say , yielding a new tree 0 (Caceres et al., 2011).
The weighted formulation specializes this local move to 3-regular phylogenetic trees. Let 1 be three consecutive edges forming a path of length 3 in 2. The NNI-operation on the triplet 3 swaps the two subtrees hanging off 4 and 5 while keeping the rest of the tree fixed; the central edge 6 is called the operating edge. In a weighted phylogeny each edge 7 has a nonnegative weight 8, and the cost of 9 is 0 (Gast et al., 2012).
These definitions induce two standard search objects. The NNI distance 1 is the minimum number of NNI moves transforming 2 into 3. In the weighted setting, the weighted NNI-distance between two weighted phylogenies 4 on the same leaf-set and the same multiset of edge-weights is
5
One often writes
6
An NNI-walk is a sequence of trees
7
where each consecutive pair 8 differ by exactly one NNI move; its length is 9, the total number of NNI steps (Caceres et al., 2011). This distinction between optimizing transformation cost and organizing a walk through a neighborhood is central to the theory of NNI search.
2. Shared edges, bad edges, and decomposability
A principal structural notion for weighted NNI search is the good edge-pair. Let 0 be two weighted phylogenies. An internal edge 1 and 2 form a good edge-pair if and only if:
- 3,
- the partition of the leaf-labels induced by removing 4 equals that induced by removing 5,
- the partition of the remaining internal-edge-weights induced by removing 6 equals that induced by removing 7 (Gast et al., 2012).
Any edge with no matching partner in the other tree is called a bad edge. Good edge-pairs can be used to split the big instance into independent smaller subinstances. This is the first step of the parallel approximation strategy: detect good edge-pairs in 8, split 9 along good edges into sub-problems, and then assume without loss of generality that no good edges remain (Gast et al., 2012).
The reduction is algorithmically significant because it isolates the part of the search space in which all internal edge weights must effectively be rearranged. In this reduced case, if 0 have no good edge-pairs and the sum of internal-edge-weights is 1, then
2
The stated proof idea is that each internal edge weight must be moved at least once (Gast et al., 2012). This lower bound is the basis for the approximation-ratio analysis of parallel NNI search.
3. Parallel approximation framework for weighted NNI-distance
The parallel algorithm of (Gast et al., 2012) works in the standard Concurrent-Read, Concurrent-Write PRAM model, assuming 3-time access to any shared memory cell and arbitrary but consistent resolution of simultaneous writes. The complexity goal is an overall running time 4 using either 5 or 6 processors, with work near-linear.
At a high level, the algorithm follows the 4-phase structure of the DasGupta-He-Jiang-Li-Tromp-Zhang (2000) sequential 7-approximation, with each subphase replaced by a parallel subroutine (Gast et al., 2012).
| Step | Operation | Stated role |
|---|---|---|
| 0 | Detect good edge-pairs | Split into sub-problems; assume no good edges remain |
| 1 | Auxiliary trees and linearization | Build balanced auxiliary trees and transform trees into linear trees |
| 2 | Sort the internal-edge sequence | Reorder internal edges by parallel block-pair merge-sort |
| 3 | Sort the leaf-permutation | Reconcile balanced trees that differ by a permutation 8 of their leaves |
| 4 | Concatenate all sequences | Obtain an 9-approximation |
The auxiliary-tree step constructs for each 0 a balanced auxiliary tree 1 of the same leaf-labels and weights, but fully height-balanced and nondecreasing from root to leaves. Both 2 and 3 are then transformed into linear trees 4 in 5 time using 6 processors. A linear tree is one in which every internal node is adjacent to at least one leaf (Gast et al., 2012).
The subsequent steps sort two different kinds of disorder. First, the internal-edge sequence of a linear tree is sorted to match a target sorted sequence. Second, once the auxiliary trees have identical internal-edge order, the residual difference is a permutation 7 of leaf labels, which is implemented by transporting leaves along paths in a balanced tree. The total weight-sum is 8, and by the lower bound 9, the algorithm achieves an 0 approximation (Gast et al., 2012).
The main theorem is stated as follows: if 1 are two weighted phylogenies on 2 leaves with the same leaf-set and edge-weight multiset, then one can compute in 3 time on 4 (or 5) CRCW-PRAM processors an NNI-sequence of total weight
6
where 7 (Gast et al., 2012).
4. Core parallel subroutines
The linearization subroutine transforms a 3-regular tree into a linear tree. It first precomputes, for each end-node 8, the path 9 upward to its first junction-node via parallel pointer-jumping in 0. It then repeats, until no junction-nodes remain, a constant-time parallel phase in which end-paths activate junction-nodes, activated junctions generate the NNI moves that insert end-paths, and pointers are updated by contraction and re-splicing. Each of the 1 iterations takes 2 time with 3 processors (Gast et al., 2012).
The edge-reordering subroutine, denoted Procedure ParallelEdgeMergeSort4, performs an 5-round parallel merge-sort of block-pairs. In round 6, the internal-edge sequence is partitioned into blocks of length 7, block-pairs are paired from the two ends inwards, and the 8 edges within each block-pair are sorted or merged by computing, for each edge, its rank in the opposite block via 9-time comparisons done in parallel. This produces a merged block of length 0 plus 1 NNI-moves per edge. The final block spans all edges in sorted order (Gast et al., 2012).
The leaf-permutation subroutine, Procedure ParallelLeafSort2, assumes balanced binary trees 3 of depth 4 with the same multiset of leaf-labels permuted by 5. It decomposes 6 into disjoint cycles in 7 time on 8 processors. In parallel for each cycle, and for each element in the cycle, it transports the corresponding leaf from its current position to its target position along the unique path via 9 moves. Since the depth is 0, each cycle takes 1 time, and the total time is 2 on 3 processors (Gast et al., 2012).
The good-edge-pair detection subroutine reduces the problem to the partition-labeling problem. Each internal edge 4 is converted into a leaf of unique new label 5 encoding 6, both trees are rooted arbitrarily, and partition-labeling is solved in 7 time on 8 processors using the method of Hon-Kao-Lam-Sung-Yiu (2004). A final scan of partition-labels in both trees identifies any label 9 occurring on exactly one internal node in 00 and one in 01 as a good edge-pair (Gast et al., 2012).
The approximation-ratio proof is additive across these subroutines. Linearization moves each internal edge at most once, so its total is at most 02. In each of the 03 merge-sort rounds, every internal edge participates in exactly one block-merge and contributes its weight once, so the total is at most 04. In leaf-sorting, each leaf transport visits 05 edges, so the total weight is also at most 06. Hence the overall cost is at most 07 for some constant 08, and therefore at most 09 (Gast et al., 2012).
5. NNI walks on SPR neighborhoods
A second line of work studies NNI search not as a shortest transformation between two fixed trees, but as a walk that visits every tree in a prescribed neighborhood. In this setting, an SPR move on 10 consists of pruning some subtree 11 by cutting an edge 12, and then regrafting 13 onto a possibly different edge of the remaining tree, followed by suppressing any resulting degree-2 node to restore binarity. The SPR-neighborhood is
14
Allen and Steel show that for any unrooted binary tree on 15 leaves,
16
The main theorem of (Caceres et al., 2011) states that for every unrooted binary tree 17 on 18 leaves, any NNI-walk that visits all trees in 19 has length
20
where 21. Equivalently,
22
for some absolute constants 23 (Caceres et al., 2011).
The proof decomposes the SPR-neighborhood into orbits. For each edge 24 of 25, the orbit 26 is the set of all trees obtained by pruning exactly 27. One checks that 28, and there are 29 edges in 30. Orbits overlap only on the original tree 31 and on those SPR-neighbors obtainable by an NNI move of 32, exactly 33 such overlaps. Within each orbit 34, there is an NNI-circuit visiting every member of 35 with at most 36 steps, which yields the upper bound when circuits are spliced back-to-back via the base tree 37. The lower bound follows because, in each orbit, all but 38 trees form a subtree of the NNI-graph that has no edges leading out of 39, forcing 40 back-and-forth steps beyond a Hamiltonian pass, and therefore 41 extra steps overall (Caceres et al., 2011).
This result settles Bryant’s Second Combinatorial Conjecture. In the language of search, it shows that if the objective is to examine every SPR-neighbor by moving only through NNI-adjacent trees, then no Hamiltonian path exists and the shortest walk necessarily incurs quadratically many revisits beyond the number of distinct neighbors (Caceres et al., 2011).
6. Algorithmic significance, heuristics, and open problems
The two lines of work describe complementary aspects of NNI search. The weighted-distance results formalize how to construct an NNI-sequence between two trees under explicit complexity and approximation guarantees. The neighborhood-walk results formalize the unavoidable overhead of restricting traversal to NNI moves while trying to cover a larger SPR neighborhood. Taken together, they indicate that local-search behavior depends not only on the cost of individual NNI operations but also on the global geometry of the target set.
Several practical implications are stated explicitly in (Gast et al., 2012). Good-edge-pair splitting suggests a divide-and-conquer NNI-search: identify cheap shared edges first, solve subproblems in parallel. The linearization and block-merge steps give a structured way to propose NNI moves in 42 phases, which can seed multithreaded hill-climbing or simulated-annealing on large trees. A stated trade-off is parallelism versus local quality: the 43-approximate solution may be far from optimal on some instances, and mixing with local descent on bad edges may improve accuracy (Gast et al., 2012).
The neighborhood results supply a complementary worst-case warning. If a search strategy must examine every SPR-neighbor by hopping via NNI moves, it will make 44 more local moves than there are distinct neighbors. The same work notes that organizing SPR neighbors into orbits and precomputing DFS-like circuits per orbit provides a systematic way to visit all one-SPR neighbors with only 45 overhead, rather than naively random-walking through NNI space (Caceres et al., 2011).
Several open questions are stated in the weighted-distance work. The APX-hardness status of weighted NNI-distance remains open. It is also asked whether one can reduce the 46 factor in the approximation ratio or improve parallel time and work, and whether the same ideas can be adapted to SPR or TBR distances (Gast et al., 2012). These questions situate NNI search at the intersection of combinatorial phylogenetics, approximation algorithms, and parallel computation.