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: A fictitious example how neighbour joining works (by Wikipedia user Tomfy).