"Network Flow" network Flow learning note PART2ISAP algorithm

Source: Internet
Author: User

To tell the truth Isap's literature is really not easy to find = and the introduction is not too detailed, unlike SAP Dinic more popular.

ISAP is actually an improved SAP algorithm, to learn ISAP first to look at the sap well. (In fact, a lot of people confuse ISAP with SAP.) Especially in China, many people will direct ISAP called SAP)

SAP algorithm (i.e. EDMONDS-KARP algorithm):

Continuously carry out the BFS to find the augmented path, then the most to find v*e times there must be no augmented path.

Time complexity O (v*e^2)

ISAP algorithm:

By maintaining the distance designator , the process of finding an augmented path is simplified to improve efficiency. The distance label can make a point to the minimum number of arcs that the sink sink, or it can be the minimum number of arcs from the source point to that point. Usually we use the former, so that when initialized, we can record the distance designator by a reverse BFS.

Assuming that the distance of point I dis[i]=dis[j]+1, then the arc (I,J) is allowed Arc , in the augmentation we only need to find the permissible arc, we can make the path must be the shortest way.

Execution of the algorithm:

First reverse BFS initialize distance label

To augment from the source point

Set current access point to point I

1> If the current I point has an arc and the arc is an allowable arc, it is executed along the arc.

2> If the current I point does not exist arc that I is the current path end, directly augmented

3> If there is an arc in the current I point but there is no allowable arc in the arc, the distance label of the update I point is the minimum value of +1 of the distance designator for all points that the arc points to, and then returns to the upper layer. When the dis[source]≥ vertex number n, the algorithm stops at the whole process.

Because Konjac Konjac is too weak to write pseudo-code, here quote @ Soft Kitten Click on the Pseudo-code to open the link

Algorithm Improved-shortest-augmenting-path1 f <--02 starting from the end point T go through the reverse BFS to obtain the starting distance label for all vertices D (i) 3 I <--S4 while D (s) < ; n Do5 If i = t then//Find the Augmented path 6 Augment7 i <--S//From source point s start next look for 8 if Gf contains an allowable arc starting from I (I,J) 9 then Advance (i) Ten else Retr Eat (i)//no allow arc to depart from I returns one return fprocedure Advance (i) 1 set (I,J) for an allowable Arc 2 pi (j) <--I//for departure from I//save a reverse path, prepare for fallback 3 I <  --J//forward further, so that J becomes the current node procedure Retreat (i) 1 d (i) <--1 + min{d (j):(I,j) belongs to the residual network GF}//The operation called re-marking 2 if I! = S3 Then I <-- Pi (i)//rewind Step Procedure Augment1 pi is recorded as the currently found augmented path P2 Delta <--Min{rij: (i,j) belongs to p}3 along path P augmented Delta Traffic 4 update residual network Gf

adjacency Table OptimizationIf more vertices, often n^2, this time to save the edge:Save the starting point of each edge, stop and value, then sort it out and record the position of each starting point. To invoke the edge from the starting point in the future, you only need to start from the record location (you can actually use the linked list). The advantage is that time accelerates space savings, and the disadvantage is that programming complexity will become larger, so it is recommended to use the adjacency matrix in the case where the topic permits. Gap OptimisationIf a distance fault occurs at the time of the re-marking, it can be proved that the St has no feasible flow, and the algorithm can be exited directly. Current ARC Optimizationin order to turn the time of the augmentation path into a single O (V), an important optimization is to save the "current arc" for each point: the initial current arc is the first arc of the adjacency table, when the adjacency table is searched from the current arc, a permit arc is found, the arc is set as the current arc, and the distance label is changed. Resets the current arc to the first arc of the adjacency table.




"Network Flow" network Flow learning note PART2ISAP algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.