Skip to content
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

MaxFlowDinic does not find blocking flows #5

Closed
godmar opened this issue Oct 27, 2014 · 1 comment
Closed

MaxFlowDinic does not find blocking flows #5

godmar opened this issue Oct 27, 2014 · 1 comment

Comments

@godmar
Copy link

godmar commented Oct 27, 2014

https://github.com/indy256/codelibrary/blob/master/java/src/MaxFlowDinic.java

In your implementation of Dinic's algorithm, you visit every edge only once in the DFS portion. This is wrong, in my opinion, as it does not guarantee that you create a blocking flow. Specifically, you may have to traverse edges more than once if you didn't saturate the path to the sink the first time.

@godmar
Copy link
Author

godmar commented Oct 28, 2014

Never mind, my bad read.

Your 'ptr[u]++' is in the 'step' clause of the for(), so you will not execute it as long as there is still remaining capacity. I had mistakenly thought that ptr[u]++ was always executed, causing you to miss edges.

@godmar godmar closed this as completed Oct 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant