Attached patch from Piotr Wygocki for min-cost max-flow