org-roam-server icon indicating copy to clipboard operation
org-roam-server copied to clipboard

[Feature request] Persist and load the same graph

Open lgmoneda opened this issue 3 years ago • 6 comments

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 physics algorithms are hard to tweak to find a good final result (a lot of overlap on nodes)
  • It takes a while to get into something you can read after opening it

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.

lgmoneda avatar Dec 05 '20 19:12 lgmoneda

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.

goktug97 avatar Dec 12 '20 08:12 goktug97

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?

lgmoneda avatar Dec 13 '20 10:12 lgmoneda

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.

goktug97 avatar Dec 13 '20 19:12 goktug97

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 avatar Dec 14 '20 12:12 lgmoneda

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 avatar Dec 14 '20 12:12 lgmoneda

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\"}}}"

lgmoneda avatar Dec 14 '20 14:12 lgmoneda