信息学竞赛的算法理论分析是个深海,趁着没掉进去,写个总结,然后赶紧去刷题...
本人不是OI选手且对理论方面的研究很少,这只是我这些天(重新)入门网络流的一个小总结,问题是大大的有的,欢迎评论!
容量,流量,可行流,残量网络等等基础概念不赘述了
2.重标优先预流推进/Relabel-to-front Algorithm
建立链表,保存当前图的拓扑序形式,不含源点汇点,按照拓扑序取点,跳过非储流点,把之前被推进过的点重新放入表头,并推进
Method | Complexity | Description |
---|---|---|
Linear programming | Constraints given by the definition of a legal flow. See the linear program here. | |
Ford–Fulkerson algorithm | $O(Emax|f|)$ | As long as there is an open path through the residual graph, send the minimum of the residual capacities on the path.
The algorithm is only guaranteed to terminate if all weights are rational. Otherwise it is possible that the algorithm will not converge to the maximum value. However, if the algorithm terminates, it is guaranteed to find the maximum value. |
Edmonds–Karp algorithm | $O(VE^2)$ | A specialization of Ford–Fulkerson, finding augmenting paths with breadth-first search. |
Dinic's blocking flow algorithm | $O(V^2E)$ | In each phase the algorithms builds a layered graph with breadth-first search on the residual graph. The maximum flow in a layered graph can be calculated in O(VE) time, and the maximum number of the phases is n-1. In networks with unit capacities, Dinic's algorithm terminates in time. |
MPM (Malhotra, Pramodh-Kumar and Maheshwari) algorithm |
$O(V^3)$ | Only works on acyclic networks. Refer to the Original Paper. |
Dinic's algorithm | $O(VE log(V))$ | The dynamic trees data structure speeds up the maximum flow computation in the layered graph to O(V E log(V)). |
General push-relabel maximum flow algorithm | $O(V^2E)$ | The push relabel algorithm maintains a preflow, i.e. a flow function with the possibility of excess in the vertices. The algorithm runs while there is a vertex with positive excess, i.e. an active vertex in the graph. The push operation increases the flow on a residual edge, and a height function on the vertices controls which residual edges can be pushed. The height function is changed with a relabel operation. The proper definitions of these operations guarantee that the resulting flow function is a maximum flow. |
Push-relabel algorithm with FIFO vertex selection rule | $O(V^3)$ | Push-relabel algorithm variant which always selects the most recently active vertex, and performs push operations until the excess is positive or there are admissible residual edges from this vertex. |
Push-relabel algorithm with dynamic trees | The algorithm builds limited size trees on the residual graph regarding to height function. These trees provide multilevel push operations. | |
KRT (King, Rao, Tarjan)'s algorithm |
||
Binary blocking flow algorithm |
The value U corresponds to the maximum capacity of the network. | |
James B Orlin's + KRT (King, Rao, Tarjan)'s algorithm |
Orlin's algorithm solves max-flow in O(VE) time for while KRT solves it in O(VE) for . |
感想....
但实际上目前竞赛中常用的算法,无论是Dinic还是ISAP或是HLPP,他们的速度都无法与单纯的最短路算法相比,就连理论上界达到$O(VE)$最高的SPFA都无法达到
而目前科学界理论下界最低的,是Orlin's提出的集大成者,复杂度上界达到$O(VE)$,但是目前还没有进入算法竞赛中来,目前所有的网络流题目复杂度都是按照O(V2E)来的但是,实际上无论是网络流还是费用流,我们目前均不需要复杂度如此低的算法
绝大多数模型都不会需要建立一个极端的稠密图/链形图,点数和边数经常是处于一个数量级的,对于$O(EV^2)$的算法足够用了
研究大量复杂度相近而实现方式不同的算法,在OI中是有意义的,
OI赛制中需要大量的不同数据来区分不同的人实力,达到区分度,这也是OI选手对于复杂度,读入输出,花式优化的精益求精的原因,
以Bellmon-Ford最短路为例,的复杂度达到了$O(VE)$
但是实际上有队列优化,不重复入队/重复入队,SLF,均值,转DFS,邻接表指针化等等不同的优化/实现方式
在不同的图中都有不同的效果,即使其理论复杂度依然是$O(VE)$,但只要选手根据不同的图去选择优化方式,就几乎无法被卡了
而且对于一个题,即使你的复杂度无法满足数据量,你依然可以通过其中很多的数据组,得到很多分,此时,一个优化到极致的算法就很重要了...
而在ICPC赛制中,区分度更多的在题目本身的思维,程序准确性,与复杂度上界,因为所有算法都通过所有的样例,也就是说必须用正确的复杂度通过,
在这种情况下,错误的复杂度毫无意义,必须选择一个复杂度稳定,编码容易,灵活的稳定算法,且从下手的一开始,就必须尝试去满足所有的极限数据和情形
OI的90分可以接受,而ICPC90分就是0分,且0ms的AC和10000ms的AC都同样正确,尤其对于网络流,建一个正确合适网络图,比花式优化的效果更大,尤其是减少多余边
甚至超过了在VJ的leaderboard中,所有公开代码里最快的dijkstra(Rank5),和第一名相当,但在ICPC中没什么用....