def _csr_gen_triples(A):
 nrows = A.shape[0]
 (data, indices, indptr) = (A.data, A.indices, A.indptr)
 for i in range(nrows):
  for j in range(indptr[i], indptr[(i + 1)]):
   (yield (i, indices[j], data[j]))

def _csr_gen_triples ( A ) : nrows = A . shape [ 0 ] ( data , indices , indptr ) = ( A . data , A . indices , A . indptr ) for i in range ( nrows ) : for j in range ( indptr [ i ] , indptr [ ( i + 1 ) ] ) : ( yield ( i , indices [ j ] , data [ j ] ) )
converts a scipy sparse matrix in **compressed sparse row** format to an iterable of weighted edge triples .