Implements min cost max flow