Calculate the hop matrix.