Numpy array of distances to list of (row,col,distance)
问题 I have an nd array that looks as follows: [[ 0. 1.73205081 6.40312424 7.21110255 2.44948974] [ 1.73205081 0. 5.09901951 5.91607978 1. ] [ 6.40312424 5.09901951 0. 1. 4.35889894] [ 7.21110255 5.91607978 1. 0. 5.09901951] [ 2.44948974 1. 4.35889894 5.09901951 0. ]] Each element in this array is a distance and I need to turn this into a list with the row,col,distance as follows: l = [(0,0,0),(0,1, 1.73205081),(0,2, 6.40312424),...,(1,0, 1.73205081),(1,1,0),...,(4,4,0)] Additionally, it would be