Closed sanobarlala closed 5 years ago
Hi, I have not encountered that error before.
To help identify what is causing this, can you identify which of the three lines that you posted results in the error (e.g. is it caused by the run_mcl, get_clusters or the draw_graph function).
Additionally, can you let me know the exact versions that you are using for: python numpy scipy networkx matplotlib
Thanks!
I think that the issue may be due to the sparse matrix format returned by networkx.
nx.to_scipy_sparse_matrix returns a sparse matrix in coo format, which is a matrix type that does not support arithmetic operations or slicing. The scipy.sparse.coo_matrix documentation states:
Once a matrix has been constructed, convert to CSR or CSC format for fast arithmetic and matrix vector operations
Can you try converting the matrix to either CSR or CSC format, then supply that to mcl. e.g.
matrix = nx.to_scipy_sparse_matrix(g).tocsc()
result = mc.run_mcl(matrix,inflation=1.4)
clusters = mc.get_clusters(result)
mc.draw_graph(matrix, clusters, pos=positions, node_size=50, with_labels=False, edge_color="silver")
If that works, then I will look into outputting a warning message if a coo matrix is supplied to run_mcl
That makes sense, I will try to implement it and get back to you. Thanks for the help!
On Tue, Dec 4, 2018 at 10:37 AM Guy Allard notifications@github.com wrote:
I think that the issue may be due to the sparse matrix format returned by networkx.
nx.to_scipy_sparse_matrix returns a sparse matrix in coo format, which is a matrix type that does not support arithmetic operations or slicing. The scipy.sparse.coo_matrix documentation states:
Once a matrix has been constructed, convert to CSR or CSC format for fast arithmetic and matrix vector operations
Can you try converting the matrix to either CSR or CSC format, then supply that to mcl. e.g.
matrix = nx.to_scipy_sparse_matrix(g).tocsc() result = mc.run_mcl(matrix,inflation=1.4) clusters = mc.get_clusters(result) mc.draw_graph(matrix, clusters, pos=positions, node_size=50, with_labels=False, edge_color="silver")
If that works, then I will look into outputting a warning message if a coo matrix is supplied to run_mcl
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/GuyAllard/markov_clustering/issues/11#issuecomment-444144015, or mute the thread https://github.com/notifications/unsubscribe-auth/ANd0_0-jlcQiH6WwZBPyZTHHB4scq320ks5u1paqgaJpZM4Y_g54 .
--
Hi, So I tried converting to both the CSC and CSR formats, but it still gives me a argmax error. I have attached to this thread, what line the error occurs in and also the versions of all the packages you mentioned above.
Thanks.
Correction: I realized I put in m instead of matrix for line 5 result=mc.run_mcl, but I fixed it and I still get the same error of argmax not found.
OK, thanks for the update. I will try and replicate the issue.
The issue is that your version of scipy (0.18.1) does not support argmax for sparse matrices - this was added in scipy 0.19.0.
I will update the requirements.
Modified setup.py to require scipy >= 0.19.0
Hi! I am passing a undirected and weighted networkx graph, g matrix = nx.to_scipy_sparse_matrix(g)
But when I try to run this code: result = mc.run_mcl(matrix,inflation=1.4)
clusters = mc.get_clusters(result) mc.draw_graph(matrix, clusters, pos=positions, node_size=50, with_labels=False, edge_color="silver")
It gives me a Attribute error: Argmax not found
DO you know why its happening?
Appreciate the help :)