Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module 'networkx' has no attribute 'to_scipy_sparse_matrix' #69

Open
Roaringman opened this issue Dec 13, 2023 · 2 comments
Open

module 'networkx' has no attribute 'to_scipy_sparse_matrix' #69

Roaringman opened this issue Dec 13, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@Roaringman
Copy link

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'

@stijnh stijnh added the bug Something isn't working label Dec 13, 2023
@stijnh
Copy link
Member

stijnh commented Dec 14, 2023

It seems that ForceAtlas is no longer maintained is no compatible with newer versions of networkx.

Relevant issue: bhargavchippada/forceatlas2#41

@stijnh
Copy link
Member

stijnh commented Dec 14, 2023

And another relevant issue: bhargavchippada/forceatlas2#45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants