Overlapping of links

Sometimes the links overlap when new nodes and links are added. How can I prevent this?

If you are using LayeredDigraphLayout, that is intentional, to separate out the independent link paths to make the relationships more clear.

But you can remove that routing by setting LayeredDigraphLayout.linkSpacing to zero.

Hmmm, the problem would be avoided if the female and male spouses swapped sides. That’s odd, because the Genogram sample’s GenogramLayout explicitly looks for this case and does the swapping of sides of the spouses. So my guess is that either you are not using that code or there is something else that is going on to prevent that from happening.

I didn’t add any code to change the ordering. When I create a marriage link, the male is put on the left and the female on the right.

When I add a parent first to the male on the left, then the female on the right, the connection is drawn properly. But when I add a parent first to the female on the right and then the male on the left it overlaps like this.

I am using model.addNodeData() function to add parent.

I’m not sure what you mean by “add a parent”. In the Genogram sample every person who has any parents has to have both parents that have a Marriage link between them. That’s because the parent-child link going to a child node is actually coming from (connected from) a label node on that Marriage link, which is how those parent-child links appear to come from the middle of the link path rather than from any node.

I want to show with an example.

There are persons A and B who do not have parents.

First I add parents to person B.

Then I add a parents to person A.

And that’s how the links overlap.