Python ig.Graph.Adjacency TypeError: can't multiply sequence by non-int of type 'numpy.float64'

Hello, when I use ig.graph.adjacency function, I got an error which is TypeError: can’t multiply sequence by non-int of type ‘numpy.float64’.
My similarity between two items are float type, for example 0.67894…
I can’t figure out why the Graph.Adjacency can not receive the float type matrix, do you have any idea about this problem? The followings are my code to reproduce this problem:

simlarity_matrix_np = sp.coo_matrix(simlarity_matrix_np)
face_graph = ig.Graph.Adjacency(simlarity_matrix_np , mode='undirected')
clusters = ig.Graph.community_walktrap(face_graph, steps=4).as_clustering()

If I change my code like the following, this problem will be fixed. But I think the adjacency should accept float type right? ```python
simlarity_matrix_np = sp.coo_matrix(simlarity_matrix_np, dtype=np.int32)
face_graph = ig.Graph.Adjacency(simlarity_matrix_np , mode=‘undirected’)
clusters = ig.Graph.community_walktrap(face_graph, steps=4).as_clustering()

I believe that you should use the Weighted_Adjacency instead.

2 Likes

Thank you! The weighted_Adjacency is works.