Network streams with upper and lower limits

Source: Internet
Author: User
For the theorem and model, see section 1. Type Simplified Ease Of Fang Method Please Solution Stream Quantity Yes Upper Lower Industry Of Network Network Medium Network Network Stream Question QuestionFor details about the process and proof of the diagram, see Amer graph theory summary.

1. The simplest thing is to find the Feasible Flow of the passive vertex graph.

If a feasible stream exists, because the traffic of each arc is greater than the lower limit, you can split each arc into a low flow and a up-low flow, add an additional source x for the required arc, an additional addition y for the required arc, and add (u, y), (x, v), the capacity is low. In this way, an equivalent network is established. The maximum stream from the source x to the appended y can make the output arc of x or y full, sufficient for the source image to have a feasible stream.

Sgu194 reactor cooling

If the source and the source are connected to an edge without the upper and lower limits (to ensure the traffic balance condition), the problem is resolved.

Poj2396 budget code: Click to view source code

2. Maximum stream

After a feasible stream is obtained, upflow attaches the source and the associated arcs to it. When a flow is solved in the residual network, upflow + flow is still a Feasible flow of the source image, therefore, if you find the maximum stream of the residual network, the maximum flow of the source image is obtained.

Zoj3229 shoot the bullet code: Click to view the source code

3. minimum stream

I have seen a lot of work on the Internet. It seems that there is a bug in the reverse extension of the residual network to find the smallest stream, or the second enumeration of the traffic from the source point to the sink point, it is more reliable and understandable to verify whether a feasible stream exists.

Sgu176 flow construction Code: Click to view the source code

4. The minimum fee flow with the upper and lower limits

Since the upper and lower bounds only limit traffic does not have much impact on the cost, you can follow the above method diagram, but you have never seen this type of question, and dare not assert ..

If it is the same as the normal largest stream, it will not be pasted...

Int getsap (int s, int t) {if (s = t) return inf; this. s = s; this. t = t; Arrays. fill (h, 0); Arrays. fill (vh, 0); // flow does not need to be cleared here !!! Int ans = 0; while (h [s]! = N) ans + = sap (s, inf); return ans;} void addcap (int a, int B, int low, int up) {buf [len] = new node (B, low, up, E [a]); E [a] = len ++; buf [len] = new node (, 0, 0, E [B]); E [B] = len ++; sumin [B] + = low; sumout [a] + = low; // init () void popcap (int I, int j) {E [j] = buf [E [j]. ne; E [I] = buf [E [I]. ne; len-= 2;} int bin (int s, int t, int k) {// The maximum stream addcap (t, s, 0, k); for (int I = 0; I <len; I ++) buf [I]. f Low = 0; int ans = getsap (n-2, n-1); popcap (s, t); return ans;} int solve (int s, int t, int mn) {int total = 0; int ss = n, tt = n + 1; for (int I = 0; I <n; I ++) {addcap (I, tt, 0, sumout [I]); addcap (ss, I, 0, sumin [I]); total + = sumin [I];} n + = 2; int ans = bin (s, t, inf); if (ans! = Total) return-1; // no feasible stream exists/* solve the minimum stream int left = 0, right = total, mid; while (left <= right) {mid = (left + right)> 1; int temp = bin (s, t, mid); if (temp = total) {ans = mid; right = mid-1;} else left = mid + 1;} bin (s, t, ans); // ans is the mininum flow */n-= 2; for (int I = n-1; I> = 0; I --) {popcap (ss, I); popcap (I, tt);} getsap (s, t ); ans = 0; for (int I = 0; I <len; I + = 2) {buf [I]. flow + = buf [I]. low; if (buf [I]. be = t) ans + = buf [I]. flow;} return ans ;}

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.