Written for CS161. Finds and returns max flow.