Skip to content

Max Flow doesn't handle v-v flow as documented #5

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

Closed
MiSawa opened this issue Sep 10, 2020 · 0 comments
Closed

Max Flow doesn't handle v-v flow as documented #5

MiSawa opened this issue Sep 10, 2020 · 0 comments

Comments

@MiSawa
Copy link
Contributor

MiSawa commented Sep 10, 2020

By definition in the document appendix.html, it should return 0 I believe.

g(v, f) = Sum{...} - Sum{...}

This implies the sum of g(v, f) over all vertices is zero.

g(v, f) = g(v, f') holds for all vertices v other than s and t.

Since s = t, this also implies g(t, f) = g(t, f'). (∵ everywhere except t is fixed, and the sum is fixed)

g(t,f′)−g(t,f) is maximized under these conditions. It returns this g(t,f′)−g(t,f)

Since g(t, f) = g(t, f'), the returned value should be 0.
Though, the actual implementation returns inf or the third argument (limit),

The current return value also makes sense if you view the problem as an instance of MaxFlow formulated as LP. You'll most likely get a primal unbounded, dual infeasible instance, depending on the choose of formulation.

Since there are multiple return values that makes some sense, both fix (fix documentation / fix implementation) would still leave confusion. So it might be better to assert(s != t) and document it.

https://github.com/rust-lang-ja/ac-library-rs/pull/24/files#r485363476

yosupo06 added a commit that referenced this issue Sep 11, 2020
yosupo06 added a commit that referenced this issue Sep 11, 2020
fix #5: maxflow was broken when s = t
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