def max_flow_min_cost(G, s, t, capacity='capacity', weight='weight'):
 maxFlow = nx.maximum_flow_value(G, s, t, capacity=capacity)
 H = nx.DiGraph(G)
 H.add_node(s, demand=(- maxFlow))
 H.add_node(t, demand=maxFlow)
 return min_cost_flow(H, capacity=capacity, weight=weight)

def max_flow_min_cost ( G , s , t , capacity = 'capacity' , weight = 'weight' ) : maxFlow = nx . maximum_flow_value ( G , s , t , capacity = capacity ) H = nx . DiGraph ( G ) H . add_node ( s , demand = ( - maxFlow ) ) H . add_node ( t , demand = maxFlow ) return min_cost_flow ( H , capacity = capacity , weight = weight )
return a maximum -flow of minimum cost .