### AmericanPsycho's blog

By AmericanPsycho, history, 4 years ago,

#### All I have read about flows is Edmonds Karp’s Algorithm, which works for maximum flow, but I have seen that there are better algorithms than this one, and there are different problems that maximum flow (like mincost, dinic and others), I would like a list of all the topics and algorithms that are useful for learning network flow!

• +8

 » 4 years ago, # |   -38 Just google ffs
•  » » 4 years ago, # ^ |   +32 why do you need to be rude? I don't think it is easy to google all these as the topic is really broad and not CP specific, so it would be nice if there is someone experienced that can summarize it as well.
•  » » » 4 years ago, # ^ |   -9 It is
•  » » » » 4 years ago, # ^ |   +10 well, not everyone is as good at googling and understanding long wikipedia and fancy math notation as you! :)
 » 4 years ago, # |   +37 To solve a network maximum flow problem you can use the Edmonds-Karp algorithm. It's a bit long, but it's easy to understand.However, like you said, there are some variation that make Edmonds-Karp not neccessarily the best option. I know there are a lot of algorithms that solve the max flow problem, but here is a list of the must used algorithms in competitive programming, and some useful topics: Edmonds-Karp Algorithm (Solves the max-flow in O(VE2)) Dinic's Algorithm (Solves the max-flow in O(V2E)) Bipartite Matching, a special case of the matching problem, which can be solved applying Edmonds-Karp via DFS. Hopcroft-Karp Algorithm, solves the bipartite matching problem with overall complexity Max Flow — Min Cut Theorem Min Cost Max Flow problem, can be solved using an Edmonds Karp variant, replacing the BFS with a fast Bellman-Ford implementation The assignment problem (and Min Weight Bipartite Matching), can be solved using min cost max flow The Hungarian Algorithm, solves the assignment problem with O(n3) complexity Push-Relabel Algorithm König's Theorem Dilworth's Theorem The last two theorems allows us to solve the Minimum Vertex Cover and Maximum Independent Set problems in bipartite graphs using flow algorithmsOne of the most important things about these kind of problems is to find that it is indeed a network flow problem. That's why these topics require a lot of practice.Personally, I find very hard to understand some algorithms like the Hungarian Method, so it is important to prepare a good library with these implementations. This way we avoid the struggle during contests!Hope you find this list useful :)
•  » » 4 years ago, # ^ |   -26 Wow! Thats a great work by you.But one could just visit this page u know..
•  » » 4 years ago, # ^ |   +1 Thank you so much. Bookmarked this comment.
 » 4 years ago, # | ← Rev. 3 →   +20 I think the topics provided by snacache is enough comprehensive. I'm going to share some links which helped me while learning network flow. Go through the 4 max flow tutorials from Topcoder tutorials index Explanation of complexity of Edmonds-Karp (I personally had a tough time understanding the reasoning behind the complexity until I saw this answer. ) Links for understanding Dinic: For mincost maxflow go through the 3 mincost maxflow tutorials given in the first link for topcoder tutorials Mincost Maxflow with SPFA (Shortest Path Faster Algorithm) achieves a better average case complexity than mincost maxflow with Bellman Ford. Learn SPFA from here
•  » » 4 years ago, # ^ |   +3 mind sharing insight like when to use dinic and when to use edmonds? Or is it solely on how dense the graph is?
•  » » » 4 years ago, # ^ | ← Rev. 2 →   +7 I actually always use Dinic. Dinic's worst case complexity ( O( V^2 * E )) is better than that of Edmond Karp ( O( V * E^2 ) ). And I haven't heard that Edmond Karp works better in any special graph than Dinic.
 » 4 years ago, # |   +6 I see others have described the algorithms and problems, I'd just add the link to an efficient implementation of Diniz's algorithm here. The page is in Russian (the English version of the page doesn't have Diniz's algorithm yet), Google Translate is your friend. Page also includes efficient implementations of other algorithms in C++.
 » 7 weeks ago, # |   0 Atcoder is having a lot of flow problems in ABCs these days. Can someone please share the list of flow problems if one has compiled.