Refactor graph function and add FordFulkerson test