org-roam / org-roam-server

A Web Application to Visualize the Org-Roam Database
MIT License
635 stars 51 forks source link

[Feature request] Persist and load the same graph #121

Open lgmoneda opened 3 years ago

lgmoneda commented 3 years ago

Thanks for the great project!

Though it's possible to set a random seed for the process, graphs can get large and it creates a couple of problems:

The suggestion is to have a "save graph" button to persist notes positions and then use this when opening org-roam-server again.

One additional advantage would be that people could exclude the "physics" and drag and drop the nodes to create the plot the way they want and then hit "save". The graph should become familiar to the person and then it's possible to concentrate on the new links created over time.

goktug97 commented 3 years ago

It should already be doing that. The node positions are saved in to the local storage when the graph is stabilized. It might be not working. I will look into it.

lgmoneda commented 3 years ago

Oh, I didn't know that. Is it a new feature?

Is it possible a graph takes too long to stabilize or it doesn't and then it's not persisted?

goktug97 commented 3 years ago

Oh, I didn't know that. Is it a new feature?

I think I implemented long time ago but not sure :D

Hmm I think I found the problem. The position storage is emptied at the start so It basicly calculates it from scratch. Fixed it https://github.com/org-roam/org-roam-server/commit/93b673209d141953547fc0732506bb0efa68f804. It should be better now. Though it still does some wiggle wiggle at the start. It might be how the library works. Can you also test it to see if it is better now.

lgmoneda commented 3 years ago

Thanks a lot for the fast solution!

I've waited for a while for my graph to get stable, but when I reloaded it restarted.

The default value for stabilization iterations is 1000. There's a 0.5 timestep I don't know if it means half a second and if I should wait 500 seconds, it is ~8 minutes, with the window active to trigger the saving function.

Then I've added a button "Save network" to execute the function "onStabilized" and it persisted the network, so the function itself works perfectly.

What I'm planning is to trigger it with physics, modify, save it, and disable physics.

Do I lose the network position when I update the package? I couldn't get where it's stored.

lgmoneda commented 3 years ago

Hm. In fact, what happens is that, though the nodes' positions are saved, the shape of their edges are different when I reload and it causes them to interact again.

For example, here's my graph after a while. I save it this way. image

When I reload, that's how it starts:

image

Then, after a while:

image

This is slightly different, but maybe defining the seed for the physical engine could solve it.

It's possible to see the positions are equal to the previous one, but the edges are not. And then the strategy of disabling physics fails because it starts with these long edges, which are not the ones I had when I saved it. I'm going to play around with the parameters to check if I can get the behavior I want. Thanks again!

lgmoneda commented 3 years ago

I don't know if all these options are needed, but with them I can persist without physics and the edges look the same:

org-roam-server-network-vis-options "{\"physics\": {\"enabled\": false, \"stabilization\": {\"enabled\": false, \"iterations\": 100}}, \"edges\": {\"physics\": false, \"length\": 5, \"hidden\": false, \"smooth\": {\"enabled\": true, \"type\": \"continuous\"}}}"