.. _store: *********************** Storing a Graph to Disk *********************** This guide will explain to you how a graph loaded into memory can be saved to disk in various formats. By doing this, you can make sub-graphs and graph data computed at runtime through analytics persistent, for future use. The resulting file can be used later as input for PGX. First, load a graph into memory and perform a ``PageRank`` analysis on it, to provide something interesting to save. To do so, you need create a new vertex property that will receive the PageRank values: .. code-block:: python :linenos: graph = session.read_graph_with_properties(self.graph_path) analyst = session.create_analyst() rank = analyst.pagerank(graph, 0.001, 0.85, 100) Next, store the graph, together with the result of the PageRank analysis and all original edge properties, as a file in edge-list format, on disk. When a graph is stored, you need to specify the graph format, a path where the file should be stored, the properties to store and a flag that specifies whether or not a file should be overwritten should a file with the same name already exist. .. code-block:: python :linenos: config = graph.store( 'edge_list', "/tmp/sample_pagerank.elist", vertex_properties=[rank], overwrite=True ) The graph data can now be found under ``/tmp/connections_pagerank.elist``. The graph configuration returned by the :meth:`store()` method can be used to load the new graph back into memory. To persist the graph configuration to disk as well, you can use the config's :meth:`str` representation to get a JSON representation: .. code-block:: python :linenos: with open("/tmp/connections_pagerank.elist.json", "w") as f: f.write(str(config))