module 'networkx' has no attribute 'to_scipy_sparse_matrix'
Hello,
Thank you for creating this great tool!
Issue:
When running litstudy.plot_cocitation_network() I get the error - module 'networkx' has no attribute 'to_scipy_sparse_matrix'.
To reproduce:
Edition Windows 10 Enterprise Version 22H2 Installed on 23-05-2023 OS build 19045.3693 Experience Windows Feature Experience Pack 1000.19053.1000.0
On both: Microsoft Edge for Business Learn more about Microsoft Edge for Business Version 120.0.2210.61 (Official build) (64-bit)
and
Google chrome Version 119.0.6045.160 (Official Build) (64-bit)
Here is the full error message:
Warning: When cdn_resources is 'local' jupyter notebook has issues displaying graphics on chrome/safari. Use cdn_resources='in_line' or cdn_resources='remote' if you have issues viewing graphics in a notebook.
AttributeError Traceback (most recent call last) Cell In[49], line 1 ----> 1 litstudy.plot_cocitation_network(docs, max_edges=500)
File ~\AppData\Local\anaconda3\envs\LitStudy\lib\site-packages\litstudy\network.py:305, in plot_cocitation_network(docs, max_edges, node_size, **kwargs)
301 """Plot a citation network.
302
303 This is a shorthand for plot_network(build_cocitation_network(docs))."""
304 b, p = split_kwargs(**kwargs)
--> 305 return plot_network(
306 build_cocitation_network(docs, max_edges=max_edges, **b),
307 # min_node_size=node_size,
308 # max_node_size=node_size,
309 **p
310 )
File ~\AppData\Local\anaconda3\envs\LitStudy\lib\site-packages\litstudy\network.py:88, in plot_network(g, height, smooth_edges, max_node_size, min_node_size, largest_component, interactive, controls, scale, iterations, gravity) 85 else: 86 sizes = [g for (_, g) in g.degree] ---> 88 layout = calculate_layout(g, gravity=gravity, iterations=iterations) 89 sizes = np.array(sizes, dtype=np.float32) 90 ratio = (max_node_size - min_node_size) / np.amax(sizes)
File ~\AppData\Local\anaconda3\envs\LitStudy\lib\site-packages\litstudy\network.py:22, in calculate_layout(g, iterations, gravity) 14 from fa2 import ForceAtlas2 16 model = ForceAtlas2( 17 verbose=True, 18 scalingRatio=1, 19 gravity=gravity, 20 ) ---> 22 matrix = nx.to_scipy_sparse_matrix(g, dtype="f", format="lil", weight="weight") 23 pos = model.forceatlas2(matrix, iterations=iterations) 25 return dict(zip(g.nodes(), pos))
AttributeError: module 'networkx' has no attribute 'to_scipy_sparse_matrix'
It seems that ForceAtlas is no longer maintained is no compatible with newer versions of networkx.
Relevant issue: https://github.com/bhargavchippada/forceatlas2/issues/41
And another relevant issue: https://github.com/bhargavchippada/forceatlas2/issues/45