Since Joseph was not the father, you need to trace Mary's lineage. miles
According to both Matthew and Luke, Joseph was the father, and it's his linage that is traced.
Of course if Joseph was not the father, then is shoots down the whole narrative of Jesus as the descendant of David.
From Matthew:
15 Elihud the father of Eleazar,
Eleazar the father of Matthan,
Matthan the father of Jacob,
16 and Jacob the father of Joseph, the husband of Mary, and Mary was the mother of Jesus who is called the Messiah.
From Luke:
3:23 And Jesus himself began to be about thirty years of age, being (as was supposed) the son of Joseph, which was the son of Heli,