Está en la página 1de 3

The Kernighan/Lin Algorithm

Next: A Sample Network for Up: Graph Partitioning Theory Previous: The Spectral Bisection Method

The Kernighan/Lin Algorithm


The Kernighan/Lin Algorithm addresses the most obvious deficiency of the breadth first search method by providing a method to improve upon an initial allocation of nodes between two subgraphs. Given a graph with nodes and weighted edges, perform the BFS method to obtain an initial and , in which is the number of

partitioning of the graph such that nodes in . Now let

, that is the cost of the partitioning for a given

is equal to the weights of all the edges that cross the partitioning. We seek to minimize . To do so, let be a subset of nodes of and be a subset of nodes in and

, such that

. If we were to switch which subgraphs

are allocated to, we would not change

the number of nodes in each of the two subgraphs. However, we could then calculate a new cost of partitioning with and ; if the cost of the new subgraphs is less than

the cost of the old subgraph, then we should accept the new subgraphs in place of the old subgraphs. The trick of the Kernighan/Lin algorithm is efficiently finding subsets of nodes and to swap. Let equal the external cost of leaving node equal the internal savings of leaving node value of switching node calculated for all nodes in into subgraph . With these is in subgraph in subgraph (i.e. (i.e. . ) and ). The can be similarly

values assigned to each node, the comparison of two and between and and is:

subgroups becomes simple. The value of switching two nodes

. Note that since subgroups, the benefit of removing

remain in different

disappears for switching. The Kernighan/Lin

Algorithm thus steps through the problem of improving a partitioning as follows:1

5555555555333 The Kernighan/Lin Algorithm:


http://zoo.cs.yale.edu/classes/cs490/02-03b/nicholas.degani/paper/node6.html (1 of 3)5/3/2007 8:07:29 PM

The Kernighan/Lin Algorithm

Compute cost( Do { Compute

) for initial partition. `

for all

in graph. `

Unmark all nodes in the graph. `

While(Unmarked nodes exist) { ` Find two unmarked nodes and , `

iterations

that maximizes

Add

and

to ordered list. `

Mark nodes

and

. `

Update as if and

for all unmarked nodes ` had switched. }

Pick

maximizing Gain, the sum of the first

gains `

on the ordered list. If Gain Update 0 {

http://zoo.cs.yale.edu/classes/cs490/02-03b/nicholas.degani/paper/node6.html (2 of 3)5/3/2007 8:07:29 PM

The Kernighan/Lin Algorithm

. ` Update . ` Update . `

} } While (Gain 0)

Note that the slowest part of the Kernighan/Lin Algorithm is the discovery of unmarked nodes that maximize the later explorations. . Also note that the Kernighan/Lin Algorithm is the basis for much of my

Next: A Sample Network for Up: Graph Partitioning Theory Previous: The Spectral Bisection Method Nicholas Anthony Degani 2003-05-11

http://zoo.cs.yale.edu/classes/cs490/02-03b/nicholas.degani/paper/node6.html (3 of 3)5/3/2007 8:07:29 PM

También podría gustarte