网络流篇
网络流问题旨在确定一个由N个城市M条水管组成的水管系统中单位时间内从城市S到城市T的最大水流量的份数。
The Network Flow Problem aims to determine the maxinum water flow value from source city S to target city T per unit time in a water pipe system consisting of N cities and M water pipes.
简单算法 simple algorithm
我们先学习了一个简单的算法,在这个算法中,每次寻找一个增广路:当找不到增广路的时候,输出答案;如果找到了一条增广路,计算这条路径所能承载的最大流量(单位时间内),然后从路径上每一条边的容量中减去这个值,再将这个最大值累加到总答案中。 举一个反例:按升序数字编号顺序搜索时,1→2(5)、1→5(2)、2→3(4)、2→4(2)、3→6(4)、4→6(2)、5→3(2),你的结果是5=4()+1()正确的最大流应为6=3()+2()+1()。
We initially studied a simple algorithm where we search for an augmenting path in each iteration. If no augmenting path is found, the answer is output. When a path is identified, we calculate the maximum flow (water units per unit time) this path can carry, subtract this value from the capacity of every edge along the path, and accumulate this maximum value to the total answer. When edges are searched in ascending numerical order (eg. for edges: 1→2(5), 1→5(2), 2→3(4), 2→4(2), 3→6(4), 4→6(2), 5→3(2)), the algorithm produces an incorrect result of 5 (calculated as 4 via + 1 via ). The true maximum flow should be 6. (calculated as 3 via + 2 via + 1 via )
Ford-Fulkerson
于是我们学习了 Ford-Fulkerson 算法,其实只是在之前的简单算法上加了一个反悔机制,每次在减去增广路上的边的流量的同时,也给这些边的反边加上这个值。显然是 的。保证它的正确性后,我们来分析这个算法的时间复杂度。举一个极端例子:1→2(1)、1→3(1)、2→3(1000000)、2→4(1)、3→4(1),我们易得最大流为2。我们来模拟一下算法:第一轮找到一个增广路 ,更新容量,第二轮,我们找到一条增广路,更新容量,第三轮,我们再次找到 ,以此类推,我们要找1000000次,每次寻找要花 的时间,这里的1000000其实就是最大容量,我们记为 ,所以 ,是个 的算法。
Edmonds-Karp
接着我们学习了 Edmonds-Karp 算法,和 Ford-fulkerson 算法的唯一区别是每次寻找的是最短增广路,显然也是 的。数学家了证明这个算法最多找NM条路径,每次寻找也要花 的时间,所以这个算法的 ,有时比 Ford-Fulkerson 慢。
Dinic
最后我们学习了 Dinic 算法,这个算法每次在寻找增广路时先构造一个分层图,再在分层图上寻找增广路,算法实现由bfs改为了dfs一次性统计所有增广路,,数学家证明了这个算法最多构造N次分层图,每次构造分层图和统计最短路花O(NM)的时间,所以这个算法的 。
应用篇
学过了算法基础后,我们就要聊聊应用了。——我自己
最大流
$$