def edmonds_karp_impl(G, s, t, capacity, residual, cutoff):
 if (s not in G):
  raise nx.NetworkXError(('node %s not in graph' % str(s)))
 if (t not in G):
  raise nx.NetworkXError(('node %s not in graph' % str(t)))
 if (s == t):
  raise nx.NetworkXError('source and sink are the same node')
 if (residual is None):
  R = build_residual_network(G, capacity)
 else:
  R = residual
 for u in R:
  for e in R[u].values():
   e['flow'] = 0
 if (cutoff is None):
  cutoff = float('inf')
 R.graph['flow_value'] = edmonds_karp_core(R, s, t, cutoff)
 return R

def edmonds_karp_impl ( G , s , t , capacity , residual , cutoff ) : if ( s not in G ) : raise nx . NetworkXError ( ( 'node %s not in graph' % str ( s ) ) ) if ( t not in G ) : raise nx . NetworkXError ( ( 'node %s not in graph' % str ( t ) ) ) if ( s == t ) : raise nx . NetworkXError ( 'source and sink are the same node' ) if ( residual is None ) : R = build_residual_network ( G , capacity ) else : R = residual for u in R : for e in R [ u ] . values ( ) : e [ 'flow' ] = 0 if ( cutoff is None ) : cutoff = float ( 'inf' ) R . graph [ 'flow_value' ] = edmonds_karp_core ( R , s , t , cutoff ) return R
implementation of the edmonds-karp algorithm .