You are on page 1of 10

3

a b Given:
4 1 2 Initial weighted graph G with
2 V(G) = { a, b, c, d, e, f }
2 c d
3 4 1
6 Start with any partition of
e f
V(G) into X and Y, say

X = { a, c, e }
Y = { b, d, f }
3 Compute the gain values of moving
a b
1
node x to the others set:
4 2
2
2 c d Dx = Ex - Ix
4
Ex = cost of edges connecting node x
3 1
6
with the other group (extra)
e f Ix = cost of edges connecting node x
within its own group (intra)
cut-size = 3+1+2+4+6 = 16
Da = Ea Ia = 3 (= 3 4 2)
X = { a, c, e } Dc = Ec Ic = 0 (= 1 + 2 + 4 4 3)
Y = { b, d, f } De = Ee Ie = + 1 (= 6 2 3)
Db = Eb Ib = + 2 (= 3 + 1 2)
Dd = Ed Id = 1 (= 2 2 1)
Df = Ef If = + 9 (= 4 + 6 1)
3
a b Cost saving when exchanging a and b is
4 1 2 essentially Da + Db
2
2 c d However, the cost saving 3 of the direct
3 4 1 edge was counted twice. But this edge
6 still connects the two groups
e f

of this exchange is gab = Da + Db - 2cab

X = { a, c, e } Da = Ea Ia = 3 (= 3 4 2)
Y = { b, d, f } Db = Eb Ib = + 2 (= 3 + 1 2)
gab = Da + Db 2cab = 7 (= 3 + 2 2.3)
3 Da = 3 Db = +2
a b
Dc = 0 Dd = 1
4 1 2
2
De = +1 Df = +9
2 c d Compute all the gains
3 4 1
gab = Da + Db 2cab = 3 + 2 23= 7
6
e f gad = Da + Dd 2cad = 3 1 20= 4
gaf = Da + Df 2caf = 3 + 9 2 0 = +6
cut-size = 16
gcb = Dc + Db 2ccb = 0 + 2 21 = 0
Pair with gcd = Dc + Dd 2ccd = 0 1 22 = 5
maximum gain gcf = Dc + Df 2ccf = 0 + 9 2 4 = +1
geb = De + Db 2ceb = +1 + 2 2 0 = +3
ged = De + Dd 2ced = +1 1 20= 0
gef = De + Df 2cef = +1 + 9 26= 2
3
a b f 1
b
4 1 2 4 1 2
3
2 2
2 c d c d
3 4 1 6 3 4
6 2
e f e a

cut-size = 16 cut-size = 16 6 = 10

Exchange nodes Then lock up


a and f nodes a and f
gaf = Da + Df 2caf = 3 + 9 2 0 = +6
f 1
b
4 1 2
3
2 = { c, e } Da = 3 Db = +2
c d
= { b, d } Dc = 0 Dd = 1
6 3 4
2
De = +1 Df = +9
e a
Update the G-values of unlocked nodes
cut-size = 10
c = Dc + 2cca 2ccf = 0 + 2(4 4) = 0
D e = De + 2cea 2cef = 1 + 2(2 6) = 7
D b = Db + 2cbf 2cba= 2 + 2(0 3) = 4
D d = Dd + 2cdf 2cda = 1 + 2(1 0) = 1
f 1
b
4 1 2 = { c, e } D c = 0 D b= 4
3
2 = { b, d } D e = 7 D d = +1
c d
6 3 4
2 Compute the gains
e a
cb =D c+D b 2ccb = 0 4 2 1 = 6
cut-size = 10
cd = D c + D d 2ccd = 0 + 1 2 2 = 3
eb = D e + D b 2ceb = 7 4 2 0 =
11
ed =D e+D d 2ced = 7 + 1 2 0 = 6
Pair with maximum gain
(can also be neative)
f 1
b f 4
b
4 2 1 1
1 3 2 3
2 2
c d d c
6 3 6 3
4 4
2 2
e a e a

cut-size = 10 cut-size = 10 ( 3) = 13

Exchange nodes Then lock up


c and d nodes c and d

cd =D c+D d 2ccd = 0 + 1 22 = 3
f b = 0
c D b= 4
4
1 1 D e= 7 D d = +1
2 3
2
d c ={e}
6 3 ={b}
4
2
e a Update the D-values of unlocked nodes

cut-size = 13 e = D e + 2ced 2cec = 7 + 2(0 3) =


1
D b = D b + 2cbd 2cbc= 4 + 2(2 1) =
2Compute the gains b= 2 D e= 1
Pair with max. gain
is (e, b) eb =D e +D b 2ceb = 1 2 20 = 3
Summary of the Gains
g = +6
g+ g 3 = +3
g+ g g 3 3=0
Maximum Gain = g = +6
Exchange only nodes a and f.
End of 1 pass.

Repeat the Kernighan-Lin.

You might also like