eliminate overlapping of nodes in vis network which consists of 8 undertrees

192 Views Asked by At

I'm dealing with a case in which the nodes are not connected enough to let vis place them correctly without overlapping.

As mentioned in the title the network consists of 8 undertress.

I attached two pictures for better understanding.

with physics off

with physics on

I read about clusters but don't know if this feature would solve the problem.

Thank you in advance

1

There are 1 best solutions below

0
On BEST ANSWER

I found a working solution for me:

I connected the nodes of the subtrees with the most relations (incoming and outgoing edges) with each other.

Then I turned physics on and turned it of after the scene has "settled".

network.on("stabilizationIterationsDone", function () {
    network.setOptions( { physics: false } );
    console.log(network.getSeed());
});

I refreshed the scene a few times and took the desired seed as randomSeed in the layout option.

I got the hint of using physics from Denis M.s blogpost: link to the blogpost