I have a sparse undirected graph stored in a scipy csr_matrix, and I need to find out the edge with maximum weight, which means that I need to find the maximum value and its corresponding row and column indices (actually I have to find the K largest values but to simplify the problem). Hence I wrote:
M=M.toarray()
for i in range(1,len(M)):
for j in range(i+1,len(M[i])):
if M[i][j] > maximum:
row,col,maximum = i,j,M[i][j]
It seems to be clumsy and performs poorly. Is there any better way to do this?