Jump to content

Kernighan–Lin algorithm: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Added section explaining the cost reduction for a directed graph
Undid revision 606295743 by 31.151.85.69 (talk)
Tag: section blanking
Line 32: Line 32:
16 '''return G(V,E)'''
16 '''return G(V,E)'''
</code>
</code>

==Directed graph==
For a directed graph, the reduction in cost of interchanging ''a'' and ''b'' is
:<math>T_{old} - T_{new} = D_{a} + D_{b}</math>
We drop the term of twice the edge cost, because <math>E_{a}+E_{b}</math> and <math>I_{a}+I_{b}</math> no longer count these double.
This reflects itself on line 7 of the algorithm where the term <math>2*c[a[i]][b[j]]</math> is dropped.


==References==
==References==

Revision as of 12:56, 29 April 2014

This article is about the heuristic algorithm for the graph partitioning problem. For a heuristic for the traveling salesperson problem, see Lin–Kernighan heuristic.

Kernighan–Lin is a O(n3 ) heuristic algorithm for solving the graph partitioning problem. The algorithm has important applications in the layout of digital circuits and components in VLSI.[1][2]

Description

Let be a graph, and let be the set of nodes and the set of edges. The algorithm attempts to find a partition of into two disjoint subsets and of equal size, such that the sum of the weights of the edges between nodes in and is minimized. Let be the internal cost of a, that is, the sum of the costs of edges between a and other nodes in A, and let be the external cost of a, that is, the sum of the costs of edges between a and nodes in B. Furthermore, let

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

where 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 and which maximizes and then executes the operations, producing a partition of the graph to A and B.[1]

Pseudocode

See [2]

 1  function Kernighan-Lin(G(V,E)):
 2      determine a balanced initial partition of the nodes into sets A and B
 3      A1 := A; B1 := B
 4      do
 5         compute D values for all a in A1 and b in B1
 6         for (n := 1 to |V|/2)
 7            find a[i] from A1 and b[j] from B1, such that g[n] = D[a[i]] + D[b[j]] - 2*c[a[i]][b[j]] is maximal
 8            move a[i] to B1 and b[j] to A1
 9            remove a[i] and b[j] from further consideration in this pass
 10           update D values for the elements of A1 = A1 \ a[i] and B1 = B1 \ b[j]
 11        end for
 12        find k which maximizes g_max, the sum of g[1],...,g[k]
 13        if (g_max > 0) then
 14           Exchange a[1],a[2],...,a[k] with b[1],b[2],...,b[k]
 15     until (g_max <= 0)
 16  return G(V,E)

References

  1. ^ a b Kernighan, B. W.; Lin, Shen (1970). "An efficient heuristic procedure for partitioning graphs". Bell Systems Technical Journal. 49: 291–307.
  2. ^ a b Ravikumār, Si. Pi (1995). Parallel methods for VLSI layout design. Greenwood Publishing Group. p. 73. ISBN 978-0-89391-828-6. OCLC 2009-06-12. {{cite book}}: Check |oclc= value (help); Unknown parameter |coauthors= ignored (|author= suggested) (help)