'Option to save the edited Pyvis network html graph file

I am using Python module pyvis to plot a network graph. Like manytimes, the initial graph is cluttered for the nodes, so i do the node moves to make it clean and better. After that i save the HTML file. When i reopen the HTML file again, the node positions which i changed for a better and clean look is reset and back to same random plotting. Is there a way i can lock the network plot after improving the node layout and positions ? is there a way we can force the java script to save also the node/edge locations,colors,lengths and reuse on next open of the graph? Where is the information about node positions stored for HTML graph? is it something computed dynamically during the java script run when HTML file is opened?



Solution 1:[1]

From the docs, you can look at this small gif:

[animated gif](https://pyvis.readthedocs.io/en/latest/_images/set_options_ex.gif)

Basically:

Once you have configured all the parameters in your graph trough the buttons:

g.show_buttons()

You can copy & paste those options inside 'set_options':

g.set_options("""
pasted_options_copied_from_generate_options_button
""")

And before run it again, comment the 'show_buttons()':

# g.show_buttons()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ricardo Alvarez