Neighbour joining is a method that infers relationships between witnesses (or organisms if using biological sequence data) by sequentially grouping those that show fewest differences. The illustration below shows this process in an example. It uses a distance matrix as input.
Fig. 1: An example how neighbour joining works from Wikipedia user Tomfy.