Solution for Introduction to Algorithms (3rd Edition) Exercise 26.4-2

Exercise 26.4-2
    Show how to implement the generic push-relabel algorithms using O(V)  time per relabel operation, O(1) time per push, and O(1) time to select an applicable operation, for total time of O(V²E).

Answer:
     Neither the source s nor the sink t can be overflowing, so they should be never relabeled. The sink t can absorb flows as much as possible, so t should be never pushed.

     Suppose an edge , u.h=v.h+1. A push operation is suggested. Once we invoke PUSH(u,v), then if u.e=0, which is a nonsaturating push, we won't push/relabel u in next loop because at that moment u are not overflowing. Otherwise, u.e>0, which is a saturating push, we can either relabel or push u in next loop. Besides, v.e must be positive because v.e is always nonnegative and we increase it while invoking PUSH(u,v). Whether we can relabel or push v is hard to judge, either.

     Let G and  denote the flow and its corresponding residual network. In, to each vertex, let u.r denote a vertex in  such that  and u.h=u.r.h+1. If such vertex doesn’t exist, u.r=NIL(the RELABEL(u) procedure will set u.r correctly). Besides we use two linked lists to implement the generic push-relabel algorithm.

    L1(waiting list): for all, u.e≤0. According to the previous statement, in next while loop, they won’t be pushed or relabeled because they are not overflowing.
    L2(pushing/relabeling list): for all, u.e>0. So they are all overflowing and we can either push or relabel them. Keep in mind that when there are no vertices in this list, the algorithm terminates.

    We append following operations while initialization. After performing old INITIALIZE-PREFLOW, for each vertex, if u.e≤0, we move it to the waiting list, or u.e>0, we move them to the pushing/relabeling list.
    Our strategy is that once we extract a vertex u from the pushing/relabeling list,we pick an applicant operation by u.r. If u.r=NIL, we relabel it, then we move it to the front of the pushing/relabeling list. Otherwise suppose u.r=v, first we check whether u.h==v.h+1, if u.h!=v.h+1, we still relabel it and move it to the front of the pushing/relabeling list, or we invoke PUSH(u,v). Every time after a PUSH(u,v) invocation, if u.e=0, we move u to the waiting list, or u.e>0 we first reset u.h=NIL and then move it to the end of the pushing/relabeling list. But v.e is positive so if we can push v in next while loop, we have to push it. Fortunately we can check it easily because we have the attribute v.r to trace. The one thing we need do is that we just move v to the front of the pushing/relabeling list after invoking PUSH(u,v) and the algorithm will judge automatically in next while loop.

    At this moment we can tell that the cost of each relabel operation is O(V), the cost of each push operation is O(1) and the cost of picking an applicant operation is O(1).
    However there still seems not perfect here. (1) After invoking PUSH(u,v), if u.e=0, we move it to the right place. Or u.e>0, we move it to the end of the pushing/relabeling list, what if we can still push u but we don’t push it immediately? Namely, in the worst case after each invocation of PUSH(u,v)(it is a saturating push exactly), we will perform an extra relabel operation. There are at most 2|V||E| saturating pushes (Lemma 26.22), so the total cost is at most, which is acceptable. (2) We extract a vertex u from the pushing/relabeling list, what if u. r=v and u.h!=v.h+1? When this kind of situation occurs we can tell that “crates have been sent back from v to u”, that is, u is still overflowing but we can’t send crates from u to v. We draw the conclusion that to each edge, at most 2|V| number of such situations will happen. u.r=v means we have performed a nonsaturating push (u,v) ago, that is, u.h=v.h+1. Now u.h!=v.h+1 means u.h≤v.h and v.h has increased. Next time we push (u,v), we still have u.h=v.h+1, that is, we have increased u.h. Thereby to each edge, we perform at most 2|V| number of relabel operation. The total cost is at most, which is also acceptable.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值