def _dok_gen_triples(A):
 for ((r, c), v) in A.items():
  (yield (r, c, v))

def _dok_gen_triples ( A ) : for ( ( r , c ) , v ) in A . items ( ) : ( yield ( r , c , v ) )
converts a scipy sparse matrix in **dictionary of keys** format to an iterable of weighted edge triples .