Skip to content

Fix a bug of MinCostMaxFlow.h#263

Open
tht2005 wants to merge 5 commits into
kth-competitive-programming:mainfrom
tht2005:patch-1
Open

Fix a bug of MinCostMaxFlow.h#263
tht2005 wants to merge 5 commits into
kth-competitive-programming:mainfrom
tht2005:patch-1

Conversation

@tht2005

@tht2005 tht2005 commented Aug 25, 2024

Copy link
Copy Markdown

Fix a bug that occur when maxflow function is called multiple times from different source vertices.

Fix a bug that occur when maxflow function is called multiple times from different source vertices.
@simonlindholm

simonlindholm commented Aug 25, 2024

Copy link
Copy Markdown
Member

It's enough to set par[s] = NULL at the start of maxflow, right? Can you modify the stress test to cover this case?

@tht2005

tht2005 commented Sep 15, 2024

Copy link
Copy Markdown
Author

I add tests for this case.

@tht2005

tht2005 commented Sep 19, 2024

Copy link
Copy Markdown
Author

It's enough to set par[s] = NULL at the start of maxflow, right? Can you modify the stress test to cover this case?

can you review my code

@simonlindholm

Copy link
Copy Markdown
Member

NULL -> 0 to save a few chars. For the test, it doesn't actually check that maxflow returns the correct result, only that it doesn't crash. Can you check that too? E.g. test it by doing "construct graph. pick random a,b,c,d. compute e = maxflow(a,b), f = maxflow(c,d). set up the same maxflow instance again. compute f' = maxflow(c, d), e' = maxflow(a, b). check that e = e', f = f'."

@Matistjati

Copy link
Copy Markdown
Contributor

Maybe I've just misunderstood this PR, but I don't think we want to support this? I don't think Simon's stated property holds. The usecase this fixes seems to be "call maxflow on multiple different source vertices in the same weakly connected component", which as far as I'm aware is a somewhat nonsensical computation? Additionally, I suspect that you might get issues with having incorrect potentials on some graphs.

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

Successfully merging this pull request may close these issues.

3 participants