Pairwise sequence distances form the symmetric matrix that tree building starts from.

highlighted = computed this step

Measure every pair

We start from 4 equal-length sequences and measure the Hamming distance between every pair — the number of columns in which they differ.

d(W,X)=#{differing columns}d(W,X) = \#\{\text{differing columns}\}
Four sequencesFour equal-length sequences to compare.WAAAAAAXAAAAGGYGGAATTZCCCCCC

Collect the distances into a matrix

The pairwise distances form a symmetric matrix with a zero diagonal. This matrix — not the sequences themselves — is the input to tree building. The closest pair here, 2, is W and X.

d(i,j)=d(j,i),d(i,i)=0d(i,j) = d(j,i), \quad d(i,i) = 0
Distance matrixEach cell is the Hamming distance between two sequences.·WXYZW0246X2046Y4406Z6660