Kernighan/Lin Algorithm[翻译]

Kernighan-Lin算法是一种局部优化策略,用于改进图分割。它从一个初步的图分区开始,通过交换节点以降低社区间的边连接成本。算法通过计算交换节点带来的增益来决定是否进行交换,目标是找到最佳分割。时间复杂度为O(|N|^3),通常在2到4次迭代后收敛。后续研究包括并行化实现和多级图分区方法。
摘要由CSDN通过智能技术生成

原文链接

算法介绍

Kernighan-Lin是一个简单的局部优化算法,该算法可以很好地改善图的分割效果。它的定义很简洁,只与边的权重有关。

This is a simple local descent algorithm, which works well to improve an already reasonable partition produced by one of the algorithm discussed later. It is simple to state for weighted edges, so we do so.

算法描述

我们将初始图G=(N,E,We)分成相等的两部分:|A|=|B|。令w(e)=w(i,j)代表e(i,j)的权值,不存在边即为0。我们的目标是找出相同数量的子集X in A和Y in B,将X和Y交换来减少AB两社区间边连接的开销。更精确的,我们令

T = sum[ a in A and b in B ] w(a,b) = cost of edges from A to B

然后寻找XY,使

new_A = A - X U Y  and  new_B = B - Y U X

间有更少的开销new_T。为了有效的计算new_T,我们介绍

  E(a) = external cost of a = sum[ b in B ] w(a,b)
  I(a) = internal cost of a = sum[ a' in A, a' != a ] w(a,a')
  D(a) = cost of a = E(a) - I(a)

类似的

  E(b) = external cost of b = sum[ a in A ] w(a,b)
  I(b) = internal cost of b = sum[ b' in B, b' != b ] w(b,b')
  D(b) = cost of b = E(b) - I(b)

容易看出,交换a in A 和 b in B 后T变化为

  new_T = T - ( D(a) + D(b) - 2*w(a,b) )
        = T - gain(a,b)

换句话说,gain(a,b) = T - ( D(a) + D(b) - 2*w(a,b) )标志着交换ab后,图分割效果的改善。与此同时D(a’)和D(b’)也改变为

  new_D(a') = D(a') + 2*w(a',a) - 2*w(a',b)  
          for all a' in A, a' != a

  new_D(b') = D(b') + 2*w(b',b) - 2*w(b',a)  
          for all b' in B, b' != b

现在我们可以定义Kernighan-Lin算法

(0)   Compute T = cost of partition N = A U B 
                             ... cost = O(|N|2)
      Repeat
(1)       Compute costs D(n) for all n in N 
                             ... cost = O(|N|2)
(2)       Unmark all nodes in G
                             ... cost = O(|N|)
(3)       While there are unmarked nodes
                             ... |N|/2 iterations
(3.1)         Find an unmarked pair (a,b) maximizing gain(a,b)
                             ... cost = O(|N|2)
(3.2)         Mark a and b (but do not swap them)
                             ... cost = O(1)
(3.3)         Update D(n) for all unmarked n, as though a and b
                   had been swapped
                             ... cost = O(|N|)
         End while
         ... 上一步中,我们计算出了一个pairs和gains的序列
         ...     (a1,b1), ... , (ak,bk) 和 
         ...     gain(1), ... , gain(k) 
         ... 其中 k = |N|/2,它们按照gain的大小顺序排列
(4)      Pick j maximizing Gain = sumi=1...j gain(i)
         ... 计算前j个pairs(a1,b1),...,(aj,bj)交换后带来的gain总和
         ... (不理解, 交换j个上一步只计算j个不就好了吗?)
(5)      If Gain > 0 then
(5.2)         Update A = A - {a1,...,aj} U {b1,...,bj}
                            ... cost = O(|N|)
(5.2)         Update B = B - {b1,...,bj} U {a1,...,aj}
                            ... cost = O(|N|)
(5.3)         Update T = T - Gain
                            ... cost = O(1)
         End if
     Until Gain <= 0

由于每次交换(ai,bi)计算的gain(i),都是在其他节点还没进行交换的前提下,所以实际上当其他节点改变时,这一值可能为负。j取得较大可能会减少计算量,但当执行一次算法循环后收益没有明显改善或为负时,可以考虑j取1,即只交换两个节点,这样可以避免只取到局部最优解。

算法的时间复杂度等于第三步的时间复杂度O(|N|^3)。迭代次数很难预测,Kernighan 和 Lin对小图(|N|<360)进行实验,根据经验得出算法会在迭代2到4次时收敛的结论。对于随机图,大概2|N|/30次时会收敛到最优解。

相关工作

  • 1987年,J. Gilbert 和 E. Zmijewski设计出并实现了Kernighan-Lin算法的并行化。
  • 更近期的,G. Karypis 和 V. Kumar 提出了”A fast and high quality multilevel scheme for partitioning irregular graphs”链接地址
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值