Max Flow Linear time algorithm, Find a valid flow - algorithm

So let me explain the question:
You are given a graph. You find the max flow. But it turns out that an edge, e_i, had the wrong capacity. It had one less. Unfortunately, the flow was maxed out at the old capacity.
Compute the new max flow in linear time (in terms of the number of edges and vertices) once you are told e_i had the wrong capacity.
Here's my plan: (1) You can't only drop the flow at edge e_i by one at an edge because you must violate certain constraints: like flow is conserved at an edge. Fix the flows so you can get a valid flow. But how?
(2) Someone has given me a hint: it will be helpful to show the valid flow = previous flow -1.mmm...
Help.

Here's a couple of tips:
Suppose you found a path with nonzero flow (i.e >= 1), and contained this edge e_i. How might you use this path to make the overall flow valid again? Now, suppose you aren't given this path. How might you get it yourself?
Now, you know that the max flow of the new graph is either the same, or one less than before (why?). How might you find out which in linear time?

Related

An 'increasing Edge' in a network flow

We are given a network flow, as well as a max flow in the network. An edge would be called increasing edge if increasing its capacity in an arbitrary positive number, would also increase the max flow.
Present an algorithm the finds an increaing edge (if one exists) and runs at $O(n^2)$.
I thought about the following idea -
Find the minimum cut in the graph, as its given to us with the ford-fulkerson algorithm.
Increase the capacity of all the edges in the left hand side of the cut by 1.
Run BFS in the residual network to find if an improved path exists. If one exists, we have an increasing edge. To find it, we have to compare the original network with the new network. We have to do that n times since we have to check for an improved path every time we increase the capacity by 1.
Is it correct, an am I in line with the required running time?
Thank you!
I think you just need to find a path from the source to the sink that would be an augmenting path if at most one node were increased in capacity.
First find all the best paths to vertices you can reach with residual capacity. If you found the sink, then you weren't given a max flow to begin with.
Then find all the other vertices that are adjacent to those ones though edges that are at capacity.
Then try to find an augmenting path from those vertices to the sink.
Total complexity is O(N), so whoever asked you this question probably had something else in mind.

Algorithm: Check if max flow is unique

A question to the following exercise:
Let N = (V,E,c,s,t) be a flow network such that (V,E) is acyclic, and let m = |E|. Describe a polynomial-
time algorithm that checks whether N has a unique maximum flow, by solving ≤ m + 1 max-flow problems.
Explain correctness and running time of the algorithm
My suggestion would be the following:
run FF (Ford Fulkerson) once and save the value of the flow v(f) and the flow over all egdes f(e_i)
for each edge e_i with f(e_i)>0:
set capacity (in this iteration) of this edge c(e_i)=f(e_i)-1 and run FF.
If the value of the flow is the same as in the original graph, then there exists another way to push the max flow through the network and we're done - the max flow isn't unique --> return "not unique"
Otherwise we continue
we're done with looping without finding another max flow of same value, that means max flow is unique -> return "unique"
Any feedback? Have I overlooked some cases where this does not work?
Your question leaves a few details open, e.g., is this an integer flow graph (probably yes, although Ford-Fulkerson, if it converges, can run on other networks as well), and how exactly do you define whether two flows are different (is it enough that the function mapping edges to flows be different, or must the set of edges actually flowing something be different, which is a stronger requirement).
If the network is not necessarily integer flows, then, no, this will not necessarily work. Consider the following graph, where, on each edge, the number within the parentheses represents the actual flow, and the number to the left of the parentheses represents the capacity (e.g., the capacity of each of (a, c) and (c, d) is 1.1, and the flow of each is 1.):
In this graph, the flow is non-unique. It's possible to flow a total of 1 by floating 0.5 through (a, b) and (b, d). Your algorithm, however, won't find this by reducing the capacity of each of the edges to 1 below its current flow.
If the network is integer, it is not guaranteed to find a different set of participating edges than the current one. You can see it through the following graph:
Finally, though, if the network is an integer flow network, and the meaning of a different flow is simply a different function of edges to flows, then your algorithm is correct.
Sufficiency If your algorithm finds a different flow with the same total result, then obviously the new flow is legal, and, also, necessarily, at least one of the edges is flowing a different amount than it did before.
Necessity Suppose there is a different flow than the original one (with the same total value), with at least one of the edges flowing a different amount. Say that, for each edge, the flow in the alternative solution is not less than the flow in the original solution. Since the flows are different, there must be at least a single edge where the flow in the alternative solution increased. Without a different edge decreasing the flow, though, there is either a violation of the conservation of flow, or the original solution was suboptimal. Hence there is some edge e where the flow in the alternative solution is lower than in the original solution. Since it is an integer flow network, the flow must be at least 1 lower on e. By definition, though, reducing the capacity of e to at least 1 lower than the current flow, will not make the alternative flow illegal. Hence some alternative flow must be found if the capacity is decreased for e.
non integer, rational flows can be 'scaled' to integer
changing edges capacity is risky, because some edges may be critical and are included in every max flow
there is a better runtime solution, you don't need to check every single edge.
create a residual network (https://en.wikipedia.org/wiki/Flow_network). run DFS on the residual network graph, if you find a circle it means there is another max flow, wherein the flow on at least one edge is different.

How to formulate LP for shortest path problems?

I'm trying to understand how the LP formulation for shortest path problem works. However I'm having trouble understanding constraints. Why does this formulation work?
http://ie.bilkent.edu.tr/~ie400/Lecture8.pdf
I'm having trouble understanding how the constraints work at pages 15 and 17. I got the main idea and I understand how and why x should take some values but I did not understand how the whole system works in terms of math. Can someone explain? In the exam, I am supposed to be able to create and modify such constraints but I am pretty far from doing that.
What isn't very clear on those slides (pp. 15 and 17) is that the line beginning with "s.t." is actually specifying one constraint per vertex i, i.e., n separate constraints in total (if there are n vertices). Normally this would be communicated by writing something like "∀i ϵ V" alongside the constraint.
In any case, this line says that for each vertex i, the total amount of flow entering it from any other vertices must equal the total amount of flow leaving it -- unless the vertex is the source, in which case the total amount of flow leaving it must be greater by 1, or the sink, in which case the total amount of flow entering it must be greater by 1. It may not be obvious how to come up with this system of constraints in the first place, but by looking at some examples you should be able to see that any shortest path (or in fact, any path from s to t at all) satisfies all of them: every internal vertex in the path will have 1 incoming edge and 1 outgoing edge, while s and t will have just 1 outgoing, or 1 incoming, edge, respectively. Vertices that don't participate in the path at all have 0 incoming and 0 outgoing flow, so they work too.
One more point is that with flow problems, very often the numbers labelling the edges represent capacity constraints -- maximum limits on the amount of flow between the two endpoints -- not costs as they do here.

Difference between s-t flow, value of flow and max flow in network flow

I am trying to understand Network Flows by reading the Klienberg and Tardos book. I have a doubt with respect to understanding the following terms and how the values of these terms change whenever we perform augmentation. This is what I have understood till now. Please correct me if this is wrong
s-t flow - This is a random path P that can be found in any graph G to carry a flow from s to t
Value of the flow - This indicates the amount of flow generated by the source
Maximum flow - Here is where I have some problems. I am unable to understand the difference between value of a flow and the maximum flow. Does max flow indicate the sum of all s-t paths in a particular graph G that can carry traffic or does it indicate the maximum among these s-t paths?
Any help here would be appreciated. Thank you
Flow is the sum of the flow along all edges out of s (or into t, which must necessarily be the same). The flow starts out at 0, and at various stages of a flow algorithm, it will gradually increase as we find more and more flow paths and add them to the overall flow. At some point, we can't find any more flow paths; then, we have obtained maximum flow (the maximum possible value of the flow). So the maximum flow is also the sum of the flow along all edges out of s (or into t), but only at the point where it is no longer possible to send more flow.
P.S. I don't have Kleinberg/Tardos, but are you sure that your definition of s-t flow is correct? If so, I understand that it sounds confusing, as "flow" typically refers to the overall flow. Cormen/Leiserson/Rivest/Stein uses what I believe to be the more common term augmenting path.

Determining minimum flow in graph with least cost given condition

I am recently preparing for the acm-icpc contest. Here I want to know how to find the minimum
flow with the least cost given the condition that each edge in the graph has a capacity C, a cost V, and a lowerbound flow L (L ≤ C).
First, I'm not sure what "minimum flow with the least cost" means, but I suspect you just mean "flow with the least cost".
Second, the lower bound flows means it is non-trivial to find an "legal flow", which is a flow where conservation of mass is respected, i.e. the sum of the inbound flows is equal to the sum of the outbound flows for all nodes except the source and the sink. (Usually flow problems have L=0 which means that the zero flow is legal.) In fact, there are choices of L and C for which no legal flow exists.
I think you could find a legal flow by starting with a flow which is equal to L on each edge. Some nodes in the graph will then have a surplus flow, and some will have a deficit flow. You can augment the flow by finding a (below capacity) path from a surplus node to a deficit node and pushing more flow along that path. Repeat until all surpluses are zero, or you can't find such a path (in which case no legal flow exists).
Once you find an admissible flow, then Ford-Fulkerson or preflow-push algorithms can then optimize your flow (modify it to lower total cost).
and good luck on your competition!
I'm a little concerned that the first solution proposed can, at best, help you find minimum max flow, which is on track to what you're looking for, but not quite the same.
I took a class taught by Robert Tarjan. He happens to have helped develop a method of deriving minimum flows called: "cycle canceling". Here is a great lecture posted by Kevin Wayne, a senior lecturer at Princeton (with Tarjan): http://www.cs.princeton.edu/~wayne/papers/ratio_talk.pdf
Min-mean circuit canceling in particular will help you to find min flows.
If you look over those two papers and still would like to discuss, please let me know.
I think your question is not well specified.
Are C, L and V single constant that apply to all edges or are they vector?
Since you are providing a minimum flow for edges, I am assuming your graph has directed edges
such that flow is possible only in one direction. The other point that needs clarification is that the cost V, is it per unit of flow? I am assuming yes, since otherwise the cost of any flow would be E.V for L > 0.
So with those assumptions, you want min cost circulation problem.

Resources