title: Save shortest path in a "structured file" using networkx and osmnx
body: <p>I have a multidimensional graph <code>G</code> and a list <code>best_path</code> calculated using the method <a href="https://networkx.org/documentation/networkx-1.10/reference/generated/networkx.algorithms.shortest_paths.generic.shortest_path.html" rel="nofollow noreferrer"><code>nx.shortest_path</code></a>.</p>
  <p>Thanks to this <a href="https://gis.stackexchange.com/questions/166515/networkx-saving-shortest-path-of-openstreetmap-data-as-an-ogr-friendly-format">stackexchange post</a>, I am exporting the x and y coordinates of my route in a simple ascii file using <code>json.dumps</code>:</p>
  <pre class="lang-py prettyprint-override"><code>parts = []
  for i in best_path:
      node = G.nodes[i]
      parts.append([float(node[&quot;y&quot;]), float(node[&quot;x&quot;])])
  json_route = json.dumps(parts)
  
  with open(current_dir + &quot;test_best_path.json&quot;, &quot;w&quot;, encoding=&quot;utf-8&quot;) as f:
      f.write(json.dumps(parts, ensure_ascii=False))
  </code></pre>
  <p>Now I am looking for a solution where I could savethis best route into a more &quot;structured&quot; file where I could also add more node attributes (e.g. yaml or graphml). Does something already exist in <code>networkx</code> or <code>osmnx</code>?</p>
  <p>Thank you</p>