Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lgmoneda opened this issue Dec 5, 2020 · 6 comments
Open

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

lgmoneda opened this issue Dec 5, 2020 · 6 comments

Comments

@lgmoneda
Copy link

lgmoneda commented Dec 5, 2020

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.

@goktug97
Copy link
Member

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
Copy link
Author

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
Copy link
Member

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 93b6732. 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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants