Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
day 24..
also day 25:
using many help from https://www.reddit.com/r/adventofcode/comments/18qbsxs/2023_day_25_solutions/, wikipedia and google.
The maximum flow of the graph between two vertices from the two subgraphs is 3. So there are 3 paths beteween any two vertices of the two graph.
So I start to find the path between 0th vertex and another vertex V=1, using BFS, and remove all edges in each path. I did it 3 times to find the 3 flows. if there's only 3 flows, the two V are disconnected. This means they are in their own subgraph. Solution found. If more flows are find, they're on the same subgraph and just consider V+=1 until solution is found. Similar to https://www.reddit.com/r/adventofcode/comments/18qbsxs/comment/keue5sc/?utm_source=share&utm_medium=web2x&context=3
This is a special case of Edmonds-Karp algorithm for solving maximum flow with capacity of 1 for each edge. The removal of edge in the above algorithm after one path found is the same as increasing the edge flow from 0 to 1 and thus preventing the next path to consider the same edge.
I didn't implement the alg for finding the actual cuts, and many other people don't. All the edges removed are a superset of the three edges that actually need to be removed. And the extra edges doesn't affect the result, by creating more subgraphs. Why?
I think I'm just luky that the topology don't have some special scenario..