MKLab-ITI / pygrank

Recommendation algorithms for large graphs
Apache License 2.0
29 stars 4 forks source link

Module 'networkx' has no attribute 'to_scipy_sparse_matrix' #21

Closed hungpham13 closed 1 year ago

hungpham13 commented 1 year ago

I encountered this issue while running benchmark.

~/.local/lib/python3.10/site-packages/pygrank/algorithms/autotune/tuning.py in rank(self, graph, personalization, *args, **kwargs)
...
---> M = G.to_scipy_sparse_array() if isinstance(G, fastgraph.Graph) else nx.to_scipy_sparse_matrix(G, weight=weight, dtype=float)
         renormalize = float(renormalize)
         left_reduction = reduction #(lambda x: backend.degrees(x)) if reduction == "sum" else reduction

AttributeError: module 'networkx' has no attribute 'to_scipy_sparse_matrix'

maniospas commented 1 year ago

Thanks for bringing this to our attention.

networkx recently depracated the to_scipy_sparse_matrix method in favor of to_scipy_sparse_array, which causes the described issue. This will be addressed in the next minor release of pygrank. It's taking some time because we are taking this opportunity to also fully transition from sparse matrices to sparse arrays. Most likely the transition will have been completed by 3/3/2023.

Temporary fix: Until the issue is correctly fixed, use networkx 2.8.8, which still provides the necessary method.

maniospas commented 1 year ago

The replicated error is fixed as of pygrank 0.2.12 (e.g., installed via pip install --upgrade pygrank). Feel free to re-open this issue if the message persists in your setup after upgrading.