almende / vis

⚠️ This project is not maintained anymore! Please go to https://github.com/visjs
7.85k stars 1.48k forks source link

[Network] Possible to layout nodes in "visual" groups? #1227

Closed glampr closed 9 years ago

glampr commented 9 years ago

I was wondering if it is possible to have nodes that belong to the same group be drawn visually close to each other, and as separately as possible from other groups.

Kind of like in this example:

AlexDM0 commented 9 years ago

Hi,

Unless you manually set the lengths of the edges, no. I don't think this will be possible in the future either.

Regards,

Alex

glampr commented 9 years ago

Hi Alex,

This was my original thought as well, but that does not work very well in all cases since nodes inside a group might not be well connected to each other (a group can even have several connected components).

Will the only other option then be to develop a custom physics solver? I can see that something like that is not supported officially but you think it could be possible?

AlexDM0 commented 9 years ago

Hi,

Sure anything is possible :). My guess would be that you'd implement an extra gravity solver, determining the center of the group each iteration and applying a force to the nodes in that group towards that center.

Come to think of it that shouldnt be too difficult. You could make a new option for nodes: physicsGroup for this. You can make two options in the physics to enable the physics groups and set the strength. physics:{groups:{enabled: true/false, strength: number}}

It could even be a fun challenge ;)

glampr commented 9 years ago

Is this something that would work on all the available solvers ('barnesHut', 'repulsion', etc...) as an addition/modification? What would be the "easiest" one to experiment with in your opinion?

AlexDM0 commented 9 years ago

The solvers are seperated, all you'd need to look at is the central gravity solver. It will then work with all the other "major" solvers.

Youd need to add the call to the solve method in the physicsEngine

glampr commented 9 years ago

I will look into this. Thanks for the help!

AlexDM0 commented 9 years ago

I'd be curious to hear if it works :) keep me posted on your progress.

Good luck!

glampr commented 9 years ago

Check out #1240

AlexDM0 commented 9 years ago

I've commented your pull. As Jos mentioned we can only accept pulls to the develop branch.

Cheers

AlexDM0 commented 9 years ago

Hi, are you still willing to update your pull or should we close it?

Regards

glampr commented 9 years ago

Feel free to close for now, you've given enough pointer so I will update it once I have more time to work on it! Thanks!