def build_flow_dict(G, R):
 flow_dict = {}
 for u in G:
  flow_dict[u] = dict(((v, 0) for v in G[u]))
  flow_dict[u].update(((v, attr['flow']) for (v, attr) in R[u].items() if (attr['flow'] > 0)))
 return flow_dict

def build_flow_dict ( G , R ) : flow_dict = { } for u in G : flow_dict [ u ] = dict ( ( ( v , 0 ) for v in G [ u ] ) ) flow_dict [ u ] . update ( ( ( v , attr [ 'flow' ] ) for ( v , attr ) in R [ u ] . items ( ) if ( attr [ 'flow' ] > 0 ) ) ) return flow_dict
build a flow dictionary from a residual network .