Convert graph object figure to networkx graph

Hi everyone,
I am coding a Dash web app which objective is to upload .csv files, visualize them into Graphs and interact with it.
Hence I have a dcc.Graph environment where I show my graph.

But when computing properties on this graph such as min. spanning tree, it recomputes the position of the nodes since the nx.spring_layout is being called over and over again, which makes the app very slow for large graphs…

I have the following idea : add a State callback with the figure property of my graph, and I would like to convert it into a nx.Graph so that I can keep the same position of the nodes, but I don’t know how to do it…

Is it possible? What other way should I explore?

Thanks a lot!