I'm trying to run this code that uses networkx to read a graph pickle file.
def read_graph(self, path=f'./dblp_graph.gpickle'):
self.g = networkx.read_gpickle(path=path)
return self.g
When I run this code using the Jupyter notebook I got following error:
module 'networkx' has no attribute 'read_gpickle'
Then, using THIS document I test networkx.readwrite.gpickle.read_gpickle instead and got this error.
module 'networkx.readwrite' has no attribute 'gpickle'
I also tried:
print(dir(nx.readwrite))
and the result is:
['GraphMLReader', 'GraphMLWriter', 'builtins', 'cached', 'doc', 'file', 'loader', 'name', 'package', 'path', 'spec', 'adjacency', 'adjacency_data', 'adjacency_graph', 'adjlist', 'cytoscape', 'cytoscape_data', 'cytoscape_graph', 'edgelist', 'forest_str', 'from_graph6_bytes', 'from_sparse6_bytes', 'generate_adjlist', 'generate_edgelist', 'generate_gexf', 'generate_gml', 'generate_graphml', 'generate_multiline_adjlist', 'generate_network_text', 'generate_pajek', 'gexf', 'gml', 'graph6', 'graphml', 'json_graph', 'leda', 'multiline_adjlist', 'node_link', 'node_link_data', 'node_link_graph', 'pajek', 'parse_adjlist', 'parse_edgelist', 'parse_gml', 'parse_graphml', 'parse_leda', 'parse_multiline_adjlist', 'parse_pajek', 'read_adjlist', 'read_edgelist', 'read_gexf', 'read_gml', 'read_graph6', 'read_graphml', 'read_leda', 'read_multiline_adjlist', 'read_pajek', 'read_sparse6', 'read_weighted_edgelist', 'relabel_gexf_graph', 'sparse6', 'text', 'to_graph6_bytes', 'to_sparse6_bytes', 'tree', 'tree_data', 'tree_graph', 'write_adjlist', 'write_edgelist', 'write_gexf', 'write_gml', 'write_graph6', 'write_graphml', 'write_graphml_lxml', 'write_graphml_xml', 'write_multiline_adjlist', 'write_network_text', 'write_pajek', 'write_sparse6', 'write_weighted_edgelist']
So, there is no function to read/write pickle files!
P.s: I also forced jupyter to use networkx version 2.5 using "!pip3 install networkx==2.5" but there is no difference.
read_gpickle
andwrite_gpickle
were removed in 3.0. – Scumble