Revised simple max flow algorithm