Minimum-cost flow problem