read json graph networkx file
<p>I'm writing a networkx graph by using this Python function:</p>
<pre><code>from networkx.readwrite import json_graph
def save_json(filename,graph):
    g = graph
    g_json = json_graph.node_link_data(g)
    json.dump(g_json,open(filename,'w'),indent=2)
</code></pre>
<p>and was trying to load the graph using:</p>
<pre><code>def read_json_file(filename):
    graph = json_graph.loads(open(filename))
    return graph
</code></pre>
<p>where the read function was taken from <a href="http://nullege.com/codes/search/networkx.readwrite.json_graph.load" rel="nofollow noreferrer">here</a>.</p>
<p>My problem is that is gives me the error:</p>
<p><code>AttributeError: 'module' object has no attribute 'load'</code></p>
<p>which makes sense, since from the networkx documentation there is no <a href="https://networkx.github.io/documentation/latest/reference/readwrite.json_graph.html#module-networkx.readwrite.json_graph" rel="nofollow noreferrer">load method</a>.</p>
<p>So, my question is how to I load a json file that contains a networkx graph?</p>