def _edge_generator_from_csr(csr_matrix):
 nrows = csr_matrix.shape[0]
 values = csr_matrix.data
 indptr = csr_matrix.indptr
 col_indices = csr_matrix.indices
 for i in range(nrows):
  for j in range(indptr[i], indptr[(i + 1)]):
   (yield (i, col_indices[j], values[j]))

def _edge_generator_from_csr ( csr_matrix ) : nrows = csr_matrix . shape [ 0 ] values = csr_matrix . data indptr = csr_matrix . indptr col_indices = csr_matrix . indices for i in range ( nrows ) : for j in range ( indptr [ i ] , indptr [ ( i + 1 ) ] ) : ( yield ( i , col_indices [ j ] , values [ j ] ) )
yield weighted edge triples for use by networkx from a csr matrix .