Genogram distance between any 2 nodes in Go Js

I have builded below genogram using go js library & my goal is to find distance of levels between any 2 nodes

Below links is what i have tried & but one of hurdle is my graph is genogram & the examples link below are linear nodes graphs hence distance is more easy to calculate.

From above graph one of note point is you can see 2 nodes with 0 & 1 ideally the node below it distance should be 1 & above distance should be 1 but its infinity since in genogram the any one spouse can have children hence other spouse distance to that child will be infinity.

Distance & path examples in genogram :

Anyways my goal is how to achieve distance between two nodes in genogram type of graph in go js & any clue or alternative path is appreciated.

Yes, the Distances and Paths sample operates on a simple graph. Genogram uses a more complex graph where each person is connected by a link to both of their biological parents via a node on a “Marriage” link between the parents.

So the problem is that the graph traversal is not detecting that the node is not a traditional node but belongs to a link, of which either end is one of the regular nodes representing a person who is a parent.

1 Like

Thanks for your answer!
I had followed one of the answer & reached the possible fix for this
Here is the link which helped on this : Is there any way to find lowest common ancestor in Genogram?