Home▸Articles▸Bioinformatics

Neighbor-Joining Phylogenetic Tree Builder (2D): A Biological Insight into Evolutionary Relationships

A powerful method for constructing phylogenetic trees that reveals evolutionary relationships among different species or organisms.

mysimulator teamUpdated June 2026≈ 3 min read▶ Open the simulation

What is Neighbor-Joining?

Neighbor-joining (NJ) is an iterative method for constructing phylogenetic trees from distance matrices. It starts with each taxon as a separate cluster and iteratively joins the two closest clusters based on their Q-criterion, which measures the increase in average pairwise distances when merging two clusters.

The NJ algorithm aims to minimize the total branch length of the tree by successively joining pairs of clusters until all taxa are joined into a single tree. This method is particularly useful for large datasets and can handle missing data well.

How Does Neighbor-Joining Work?

At each step, the NJ algorithm calculates the Q-criterion for every pair of clusters to determine which two should be joined next. The Q-criterion is defined as: Q(i,j) = (d(i,j) - d(i,k) - d(j,l)) / 2, where i and j are the clusters being considered, k and l are all other taxa not in these clusters, and d represents the distance between any two taxa. The pair with the smallest Q-criterion is joined first.

Once a pair of clusters is chosen, their distances to other clusters are updated according to the new cluster formed by joining them. This process continues iteratively until only one cluster remains, resulting in a complete tree.

live demo · related simulation● LIVE

Why Does Neighbor-Joining Matter?

Neighbor-joining is significant because it provides a straightforward and computationally efficient way to construct phylogenetic trees. It has been widely used in molecular biology for analyzing genetic data, such as DNA sequences, to understand evolutionary relationships among different organisms.

Moreover, the NJ method can handle large datasets with missing or incomplete information, making it a robust tool for bioinformatics research.

Real-World Applications

Neighbor-joining has numerous applications in various fields of biology. For example, it is used to study the evolution of viruses, such as influenza and HIV, by analyzing genetic sequences from different strains.

In ecology, NJ can help construct trees that reveal the evolutionary relationships among species within a particular ecosystem or geographic region.

Frequently asked questions

What is the Q-criterion in neighbor-joining?

The Q-criterion measures the increase in average pairwise distances when merging two clusters. It helps determine which pair of clusters should be joined next in the algorithm.

How does neighbor-joining handle missing data?

Neighbor-joining can effectively handle missing data by updating distances between clusters based on the available information, making it a robust method for constructing phylogenetic trees from incomplete datasets.

Why is neighbor-joining considered computationally efficient?

Neighbor-joining is computationally efficient because it iteratively joins pairs of clusters with the smallest Q-criterion, which reduces the complexity compared to other methods that consider all possible tree topologies.

Can neighbor-joining be used for non-biological data?

While neighbor-joining was originally developed for biological applications, it can also be applied to any dataset where pairwise distances are available, such as in social network analysis or clustering of gene expression data.

Try it live

Everything above runs in your browser — open Neighbor-Joining Phylogenetic Tree Builder (2D) and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.

▶ Open Neighbor-Joining Phylogenetic Tree Builder (2D) simulation

What did you find?

Add reproduction steps (optional)