This is the structure of my family graph
I tried solving this with the commonly used
Least Common Ancestor
algorithm and was successful to some extent. The algorithm can find relationships having common ancestors like3 and 8
and1 and 8
However the algorithm fails to find relationships between (For instance)3 and 11
and3 and 4
In these cases there is no common ancestor.
In the given image 6,7 and 9,8 and 10,11 and 4,5 are couples, so I could add another connection between either of them to form a marriage link.
Is there an alternative approach to the
LCA
algorithm to find relationships between nodes that don't have common ancestors?The ultimate aim is to answer questions like 3 is the grandson of 9 and 3 is the nephew/niece of 10.