Lably
Skip to content

Kernighan–Lin algorithm

Heuristic algorithm for finding partitions of graphs

  • 2 min read
  • 2 chapters

Related on Lably

Through Graph (discrete mathematics)

Description

The input to the algorithm is an undirected graph G = (V, E) with vertex set V, edge set E, and (optionally) numerical weights on the edges in E. The goal of the algorithm is to partition V into two disjoint subsets A and B of equal (or nearly equal) size, in a way that minimizes the sum T of the weights of the subset of edges that cross from A to B. If the graph is unweighted, then instead the goal is to minimize the number of crossing edges; this is equivalent to assigning weight one to each edge. The algorithm maintains and improves a partition, in each pass using a greedy algorithm to pair up vertices of A with vertices of B, so that moving the paired vertices from one side of the partition to the other will improve the partition. After matching the vertices, it then performs a subset of the pairs chosen to have the best overall effect on the solution quality T. Given a graph with n vertices, each pass of the algorithm runs in time O(n2 log n).

In more detail, for each a∈A, let Ia be the internal cost of a, that is, the sum of the costs of edges between a and other nodes in A, and let Ea be the external cost of a, that is, the sum of the costs of edges between a and nodes in B. Similarly, define Ib, Eb for each b∈B. Furthermore, let

Ds=Es−Is

be the difference between the external and internal costs of s. If a and b are interchanged, then the reduction in cost is

Told−Tnew=Da+Db−2ca,b

where ca,b is the cost of the possible edge between a and b.

The algorithm attempts to find an optimal series of interchange operations between elements of A and B which maximizes Told−Tnew and then executes the operations, producing a partition of the graph to A and B.

Sign in to keep reading

One more chapter is free with a Lably account.

More in Computing and communication