We obtain the following values for the matrix (the diagonal elements of the matrix are not used and are
omitted here):
a
b
c
d
e
a
—
−47.7
−49.0
−45.0
−49.7
b
−47.7
—
−43.3
−45.3
−55.0
c
−49.0
−43.3
—
−56.7
−42.3
d
−45.0
−45.3
−56.7
—
−44.3
e
−49.7
−55.0
−42.3
−44.3
—
In the example above, . This is the smallest value of , so we join elements and .
First branch length estimation
Let denote the new node. By equation (2), above, the branches joining and to then have lengths:
First distance matrix update
We then proceed to update the initial distance matrix into a new distance matrix (see below), reduced in size by one row and one column because of the joining of with into their neighbor . Using equation (3) above, we compute the distance from to each of the other nodes besides and . In this case, we obtain:
The resulting distance matrix is:
u
c
d
e
u
0
7
7
6
c
7
0
8
7
d
7
8
0
3
e
6
7
3
0
Bold values in correspond to the newly calculated distances, whereas italicized values are not affected by the matrix update as they correspond to distances between elements not involved in the first joining of taxa.
We may choose either to join and , or to join and ; both pairs have the minimal value of , and either choice leads to the same result. For concreteness, let us join and and call the new node .
Second branch length estimation
The lengths of the branches joining and to can be calculated:
The joining of the elements and the branch length calculation help drawing the neighbor joining tree as shown in the figure.
Second distance matrix update
The updated distance matrix for the remaining 3 nodes, , , and , is now computed:
This example represents an idealized case: note that if we move from any taxon to any other along the branches of the tree, and sum the lengths of the branches traversed,
the result is equal to the distance between those taxa in the input distance matrix. For example, going from to we have . A distance matrix whose distances agree in this way with some tree is said to be 'additive', a property which is rare in practice. Nonetheless it is important to note that, given an additive distance matrix as input, neighbor joining is guaranteed to find the tree whose distances between taxa agree with it.