min cost flow algorithm