Run flow algorithm