26.5 The relabel-to-front algorithm
26.5-1
Illustrate the execution of in the manner of Figure 26.10 for the flow network in Figure 26.1(a). Assume that the initial ordering of vertices in is and that the neighbor lists are
When we initialize the preflow, we have units of flow leaving . Then, we consider since it is the first element in the list. When we discharge it, we increase it's height to so that it can dump of it's excess along its edge to vertex , to discharge the rest of it, it has to increase it's height to to discharge it back to . It was already at the front, so, we consider . We increase its height to . Then, we send all of its excess along its edge to . We move it to the front, which means we next consider , and do nothing because it is not overflowing. Up next is vertex . After increasing its height to , it can send all of its excess to . This puts at the front, and we consider the non-overflowing vertices and . Then, we consider , it increases its height to , then sends units to . Since it still has an excess of units, it increases its height once again. Then it becomes valid for it to send flow back to or to . It considers first because of the ordering of its neighbor list. This means that units of flow are pushed back to . Since increased, it moves to the front of the list Then, we consider since it is the only still overflowing vertex. We increase its height to . Then, it is overflowing by so it increases its height to to send units to . It's height increased so it goes to the of the list. Then, we consider , which is overflowing. It pushes units to . Since it is still overflowing by , it increases its height to and pushes the rest back to and goes to the front of the list. Up next is , which increases its height by to sends its overflow to . The excess flow keeps bobbing around the four vertices, each time requiring them to increase their height a bit to discharge to a neighbor only to have that neighbor increase to discharge it back until has increased in height enough to send all of it's excess back to s. Last but not least, pushes its overflow of units to , and gives us a maximum flow of .
26.5-2
We would like to implement a push-relabel algorithm in which we maintain a firstin, first-out queue of overflowing vertices. The algorithm repeatedly discharges the vertex at the head of the queue, and any vertices that were not overflowing before the discharge but are overflowing afterward are placed at the end of the queue. After the vertex at the head of the queue is discharged, it is removed. When the queue is empty, the algorithm terminates. Show how to implement this algorithm to compute a maximum flow in time.
Initially, the vertices adjacent to are the only ones which are overflowing. The implementation is as follows:
PUSH-RELABEL-QUEUE(G, s)
INITIALIZE-PREFLOW(G, s)
let q be a new empty queue
for v ∈ G.Adj[s]
PUSH(q, v)
while q.head != NIL
DISCHARGE(q.head)
POP(q)
Note that we need to modify the algorithm to push vertices onto the queue if was not overflowing before a discharge but is overflowing after one.
Between lines 7 and 8 of , add the line "if , ." This is an implementation of the generic push-relabel algorithm, so we know it is correct. The analysis of runtime is almost identical to that of Theorem 26.30. We just need to verify that there are at most calls to between two consecutive relabel operations. Observe that after calling , Corollary 26.28 tells us that no admissible edges are entering . Thus, once is put into the queue because of the push, it can't be added again until it has been relabeled. Thus, at most vertices are added to the queue between relabel operations.
26.5-3
Show that the generic algorithm still works if updates by simply computing . How would this change affect the analysis of ?
If we change relabel to just increment the value of , we will not be ruining the correctness of the Algorithm. This is because since it only applies when , we won't be every creating a graph where ceases to be a height function, since will only ever be increasing by exactly whenever relabel is called, ensuring that . This means that Lemmatae 26.15 and 26.16 will still hold. Even Corollary 26.21 holds since all it counts on is that relabel causes some vertex's value to increase by at least , it will still work when we have all of the operations causing it to increase by exactly . However, Lemma 26.28 will no longer hold. That is, it may require more than a single relabel operation to cause an admissible edge to appear, if for example, was strictly less than the values of all its neighbors. However, this lemma is not used in the proof of Exercise 26.4-3, which bounds the number of relabel operations. Since the number of relabel operations still have the same bound, and we know that we can simulate the old relabel operation by doing (possibly many) of these new relabel operations, we have the same bound as in the original algorithm with this different relabel operation.
26.5-4
Show that if we always discharge a highest overflowing vertex, we can make the push-relabel method run in time.
We'll keep track of the heights of the overflowing vertices using an array and a series of doubly linked lists. In particular, let be an array of size , and let store a list of the elements of height . Now we create another list , which is a list of lists. The head points to the list containing the vertices of highest height. The next pointer of this list points to the next nonempty list stored in , and so on. This allows for constant time insertion of a vertex into , and also constant time access to an element of largest height, and because all lists are doubly linked, we can add and delete elements in constant time. Essentially, we are implementing the algorithm of Exercise 26.5-2, but with the queue replaced by a priority queue with constant time operations. As before, it will suffice to show that there are at most calls to discharge between consecutive relabel operations.
Consider what happens when a vertex is put into the priority queue. There must exist a vertex for which we have called . After this, no ad- missible edge is entering , so it can't be added to the priority queue again until after a relabel operation has occurred on . Moreover, every call to terminates with a , so for every call to there is another vertex which can't be added until a relabel operation occurs. After operations and no relabel operations, there are no remaining valid operations, so either the algorithm terminates, or there is a valid relabel operation which is performed. Thus, there are calls to . By carrying out the rest of the analysis of Theorem 26.30, we conclude that the runtime is .
26.5-5
Suppose that at some point in the execution of a push-relabel algorithm, there exists an integer for which no vertex has . Show that all vertices with are on the source side of a minimum cut. If such a exists, the gap heuristic updates every vertex for which , to set . Show that the resulting attribute is a height function. (The gap heuristic is crucial in making implementations of the push-relabel method perform well in practice.)
Suppose to try and obtain a contradiction that there were some minimum cut for which a vertex that had were on the sink side of that cut. For that minimum cut, there is a residual flow network for which that cut is saturated. Then, if there were any vertices that were also on the sink side of the cut which had an edge going to in this residual flow network, since it's value cannot be equal to , we know that it must be greater than since it could be only at most one less than . We can continue in this way to let be the set of vertices on the sink side of the graph which have an value greater than . Suppose that there were some simple path from a vertex in to . Then, at each of these steps, the height could only decrease by at most , since it cannot get from above to without going through , we know that there is no path in the residual flow network going from a vertex in to . Since a minimal cut corresponds to disconnected parts of the residual graph for a maximum flow, and we know there is no path from to , there is a minimum cut for which lies entirely on the source side of the cut. This was a contradiction to how we selected , and so have shown the first claim.
Now we show that after updating the values as suggested, we are still left with a height function. Suppose we had an edge in the residual graph. We knew from before that . However, this means that if , so must be . So, if both were above , we would be making them equal, causing the inequality to still hold. Also, if just were above , then we have not decreased it's value, meaning that the inequality also still must hold. Since we have not changed the value of , and , we have all the required properties to have a height function after modifying the values as described.