-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in augmenting flow calculation #1
Comments
Also, the algorithm as implemented is actually Edmonds-Karp, which is more efficient and a special case of FF When calculating a path source->sink FF uses any algorithm, while EK uses BFS specifically (as is the case here) |
Hi, thanks for the thoughtful review! Some thoughts below
I kinda wish I wrote a test for this, :( when I did put this together. Unfortunately, Universities are slow to instill a unit-testing culture |
Surprised you answered, and quite prompty too.
looping on iterators is compiled/interpreted like so:
turns into:
so making
The reason turning it into a list solves the issue is that you read it once into the list (so full list, empty iterator), and then each time you use it you iterate over a list, which doesn't empty it. (If you wanna get really technical, iterating over list actually iters over Here are 2 great short videos on the subject: |
You're totally right, I didn't realize that |
Hi!
I'm using this (with credit) for a benchmarking assignment and I noticed a bug in augmenting flow calculation.
Because flow_path is created as a zip it's an iterable.
This means that in augment_flow, after being read for bottleneck calculation, flow_path is emptied and the for loop that would actually augment the path runs over an empty iterator and halts immediately.
An easy fix is to list the zip before calling augment_flow
ford-fulkerson-max-flow/ford_fulkerson.py
Line 38 in e3fd248
...
ford-fulkerson-max-flow/ford_fulkerson.py
Lines 13 to 15 in e3fd248
I'm just leaving this here to clear confusion for future people
The text was updated successfully, but these errors were encountered: