Graph Partitioning Problem Kernighan and Lin Algorithm

Slides:



Advertisements
Similar presentations
Minimum Spanning Tree Sarah Brubaker Tuesday 4/22/8.
Advertisements

Tutorial 6 of CSCI2110 Bipartite Matching Tutor: Zhou Hong ( 周宏 )
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
VLSI Layout Algorithms CSE 6404 A 46 B 65 C 11 D 56 E 23 F 8 H 37 G 19 I 12J 14 K 27 X=(AB*CD)+ (A+D)+(A(B+C)) Y = (A(B+C)+AC+ D+A(BC+D)) Dr. Md. Saidur.
VLSI Layout Algorithms CSE 6404 A 46 B 65 C 11 D 56 E 23 F 8 H 37 G 19 I 12J 14 K 27 X=(AB*CD)+ (A+D)+(A(B+C)) Y = (A(B+C)+AC+ D+A(BC+D)) Dr. Md. Saidur.
Great Theoretical Ideas in Computer Science.
Fast algorithm for detecting community structure in networks.
A scalable multilevel algorithm for community structure detection
Traveling Salesman Problems Repetitive Nearest-Neighbor and Cheapest-Link Algorithms Chapter: 6.
CS267 L15 Graph Partitioning II.1 Demmel Sp 1999 CS 267 Applications of Parallel Computers Lecture 15: Graph Partitioning - II James Demmel
Colored Necklace Bisection Victor Kostyuk Advisor: Michael Capalbo.
Partitioning 1 Outline –What is Partitioning –Partitioning Example –Partitioning Theory –Partitioning Algorithms Goal –Understand partitioning problem.
Chapter 9: Graphs Basic Concepts
Multilevel Graph Partitioning and Fiduccia-Mattheyses
More Chapter 7: Greedy Algorithms Kruskal’s Minimum Spanning Tree Algorithm.
Partitioning Outline –What is Partitioning –Partitioning Example –Partitioning Theory –Partitioning Algorithms Goal –Understand partitioning problem –Understand.
Graph Coloring.
Domain decomposition in parallel computing Ashok Srinivasan Florida State University COT 5410 – Spring 2004.
Graph partition in PCB and VLSI physical synthesis Lin Zhong ELEC424, Fall 2010.
Design and Analysis of Computer Algorithm September 10, Design and Analysis of Computer Algorithm Lecture 5-2 Pradondet Nilagupta Department of Computer.
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Greedy methods Prudence Wong
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
Minimum spanning trees Aims: To know the terms: tree, spanning tree, minimum spanning tree. To understand that a minimum spanning tree connects a network.
1 Min-cut for Undirected Graphs Given an undirected graph, a global min-cut is a cut (S,V-S) minimizing the number of crossing edges, where a crossing.
CSE 494: Electronic Design Automation Lecture 4 Partitioning.
APPROXIMATION ALGORITHMS VERTEX COVER – MAX CUT PROBLEMS
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 26.
Chapter 4 sections 1 and 2.  Fig. 1  Not connected  All vertices are even.  Fig. 2  Connected  All vertices are even.
Vertices and Edges Introduction to Graphs and Networks Mills College Spring 2012.
10/25/ VLSI Physical Design Automation Prof. David Pan Office: ACES Lecture 3. Circuit Partitioning.
Computing the chromatic number for block intersection graphs of Latin squares Ed Sykes CS 721 project McMaster University, December 2004 Slide 1.
Spanning Trees. A spanning tree for a connected, undirected graph G is a graph S consisting of the nodes of G together with enough edges of G such that:
Chapter 11 – Counting Methods Intro to Counting Methods Section 11.1: Counting by Systematic Listing.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
1/24 Introduction to Graphs. 2/24 Graph Definition Graph : consists of vertices and edges. Each edge must start and end at a vertex. Graph G = (V, E)
WK15. Vertex Cover and Approximation Algorithm By Lin, Jr-Shiun Choi, Jae Sung.
Circuit Partitioning Divides circuit into smaller partitions that can be efficiently handled Goal is generally to minimize communication between balanced.
Graphs A ‘Graph’ is a diagram that shows how things are connected together. It makes no attempt to draw actual paths or routes and scale is generally inconsequential.
Domain decomposition in parallel computing Ashok Srinivasan Florida State University.
ICS 252 Introduction to Computer Design
Network Theory: Community Detection Dr. Henry Hexmoor Department of Computer Science Southern Illinois University Carbondale.
CprE566 / Fall 06 / Prepared by Chris ChuPartitioning1 CprE566 Partitioning.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Algorithm Design and Analysis June 11, Algorithm Design and Analysis Pradondet Nilagupta Department of Computer Engineering This lecture note.
1 Data Structures and Algorithms Graphs. 2 Graphs Basic Definitions Paths and Cycles Connectivity Other Properties Representation Examples of Graph Algorithms:
CS 140: Sparse Matrix-Vector Multiplication and Graph Partitioning
1 Minimum Routing Cost Tree Definition –For two nodes u and v on a tree, there is a path between them. –The sum of all edge weights on this path is called.
COMP108 Algorithmic Foundations Greedy methods
Spanning Trees.
Combinations COURSE 3 LESSON 11-3
Chapter 2 – Netlist and System Partitioning
CSCE350 Algorithms and Data Structure
Graphs Representation, BFS, DFS
Haim Kaplan and Uri Zwick
CSE373: Data Structures & Algorithms Lecture 20: Minimum Spanning Trees Linda Shapiro Spring 2016.
Single Source Shortest Paths Bellman-Ford Algorithm
Graphs.
Example A cable company want to connect five villages to their network which currently extends to the market town of Avonford. What is the minimum.
Minimum spanning trees
Splash Screen.
Minimum Spanning Trees
AB AC AD AE AF 5 ways If you used AB, then, there would be 4 remaining ODD vertices (C, D, E and F) CD CE CF 3 ways If you used CD, then, there.
Minimum spanning trees
A Fundamental Bi-partition Algorithm of Kernighan-Lin
Splash Screen.
Algorithms (2IL15) – Lecture 7
Splash Screen.
Kruskal’s Algorithm AQR.
Closures of Relations Epp, section 10.1,10.2 CS 202.
GRAPHS.
Presentation transcript:

Graph Partitioning Problem Kernighan and Lin Algorithm Presentation based on http://www.comp.nus.edu.sg/~cs5234/2007-08/Lectures/L06/L06-Graph-Partitioning.ppt

Sparse Matrix partitioning

Graph Segmentation To partition N into 2k parts bisect (i.e. cut into two pieces) graph recursively k times

Problem Formulation Input: A weighted graph G = (V, E) with Vertex set V. (|V| = 2n) Edge Set E. (|E| = e) Cost cAB for each edge (A, B) in E. Output: 2 subsets X & Y such that V = X  Y and X  Y = { } (i.e. partition) Each subset (group) has n vertices Total cost of edges “crossing” the partition is minimized. This problem is NP-Complete!!!!!

Brute Force Method Try all possible bisections. Choose the best one. If there are 2n vertices, # of possibilities = (2n)! / (n!)2 = nO(n) For 4 vertices (A,B,C,D), 3 possibilities 1. X = {A, B} & Y = {C, D} 2. X = {A, C} & Y = {B, D} 3. X = {A, D} & Y = {B, C} For 100 vertices, 5 x 1028 possibilities! Brute force not possible!

Kernighan and Lin heuristic “An Efficient Heuristic Procedure for Partitioning Graphs” B. W. Kernighan and S. Lin, The Bell System Technical Journal, 49(2):291-307, 1970

Idea of KL Algorithm Start with any initial partition X and Y. A pass or iteration means exchanging each vertex A  X with each vertex B  Y exactly once: 1. For i := 1 to n do From the unlocked (unexchanged) vertices, choose a pair (A,B) s.t. gain(A,B) is largest. Exchange A and B. Lock A and B. Let gi = gain(A,B). 2. Find the k s.t. G=g1+...+gk is maximized. 3. Switch the first k pairs. Repeat the pass until there is no improvement (G=0).

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

KL algorithm (2a) 3 Compute the gain values of moving node x to the others set: Gx = Ex - Ix Ex = cost of edges connecting node x with the other group (extra) Ix = cost of edges connecting node x within its own group (intra) a b 4 1 2 2 2 c d 3 4 1 6 e f cut-size = 3+1+2+4+6 = 16 Ga = Ea – Ia = – 3 (= 3 – 4 – 2) Gc = Ec – Ic = 0 (= 1 + 2 + 4 – 4 – 3) Ge = Ee – Ie = + 1 (= 6 – 2 – 3) Gb = Eb – Ib = + 2 (= 3 + 1 –2) Gd = Ed – Id = – 1 (= 2 – 2 – 1) Gf = Ef – If = + 9 (= 4 + 6 – 1) X = { a, c, e } Y = { b, d, f }

KL algorithm (2b) 3 a b Cost saving when exchanging a and b is essentially Ga + Gb However, the cost saving 3 of the direct edge was counted twice. But this edge still connects the two groups Hence, the real “gain” (i.e. cost saving) of this exchange is gab = Ga + Gb - 2cab 4 1 2 2 2 c d 3 4 1 6 e f Ga = Ea – Ia = – 3 (= 3 – 4 – 2) Gb = Eb – Ib = + 2 (= 3 + 1 – 2) gab = Ga + Gb – 2cab = – 7 (= – 3 + 2 – 2.3) X = { a, c, e } Y = { b, d, f }

KL algorithm (3) Ga = –3 Gb = +2 Gc = 0 Gd = –1 Ge = +1 Gf = +9 4 6 Compute all the gains gab = Ga + Gb – 2wab = –3 + 2 – 23 = –7 gad = Ga + Gd – 2wad = –3 – 1 – 20 = –4 gaf = Ga + Gf – 2waf = –3 + 9 – 20 = +6 gcb = Gc + Gb – 2wcb = 0 + 2 – 21 = 0 gcd = Gc + Gd – 2wcd = 0 – 1 – 22 = –5 gcf = Gc + Gf – 2wcf = 0 + 9 – 24 = +1 geb = Ge + Gb – 2web = +1 + 2 – 20 = +3 ged = Ge + Gd – 2wed = +1 – 1 – 20 = 0 gef = Ge + Gf – 2wef = +1 + 9 – 26 = –2 cut-size = 16 Pair with maximum gain

Then lock up nodes a and f KL algorithm (4) a c b d e f 3 1 2 4 6 a c b d e f 3 1 2 4 6 cut-size = 16 cut-size = 16 – 6 = 10 Exchange nodes a and f Then lock up nodes a and f gaf = Ga + Gf – 2caf = –3 + 9 – 20 = +6

KL algorithm (5) Ga = –3 Gb = +2 Gc = 0 Gd = –1 Ge = +1 Gf = +9 4 6 X’ = { c, e } Y’ = { b, d } Update the G-values of unlocked nodes cut-size = 10 G’c = Gc + 2cca – 2ccf = 0 + 2(4 – 4) = 0 G’e = Ge + 2cea – 2cef = 1 + 2(2 – 6) = –7 G’b = Gb + 2cbf – 2cba= 2 + 2(0 – 3) = –4 G’d = Gd + 2cdf – 2cda = –1 + 2(1 – 0) = 1

Pair with maximum gain (can also be neative) KL algorithm (6) G’c = 0 G’b = –4 G’e = –7 G’d = +1 a c b d e f 3 1 2 4 6 X’ = { c, e } Y’ = { b, d } Compute the gains g’cb = G’c + G’b – 2ccb = 0 – 4 – 21 = –6 g’cd = G’c + G’d – 2ccd = 0 + 1 – 22 = –3 g’eb = G’e + G’b – 2ceb = –7 – 4 – 20 = –11 g’ed = G’e + G’d – 2ced = –7 + 1 – 20 = –6 cut-size = 10 Pair with maximum gain (can also be neative)

Then lock up nodes c and d KL algorithm (7) a c b d e f 3 1 2 4 6 a d b c e f 3 1 2 4 6 cut-size = 10 cut-size = 10 – (–3) = 13 Exchange nodes c and d Then lock up nodes c and d g’cd = G’c + G’d – 2ccd = 0 + 1 – 22 = –3

Pair with max. gain is (e, b) KL algorithm (8) a d b c e f 3 1 2 4 6 G’c = 0 G’b = –4 G’e = –7 G’d = +1 X” = { e } Y” = { b } Update the G-values of unlocked nodes G”e = G’e + 2ced – 2cec = –7 + 2(0 – 3) = –1 G”b = G’b + 2cbd – 2cbc= –4 + 2(2 – 1) = –2 cut-size = 13 Compute the gains Pair with max. gain is (e, b) g”eb = G”e + G”b – 2ceb = –1 – 2 – 20 = –3

KL algorithm (9) Summary of the Gains… Maximum Gain = g = +6 g + g’ = +6 – 3 = +3 g + g’ + g” = +6 – 3 – 3 = 0 Maximum Gain = g = +6 Exchange only nodes a and f. End of 1 pass. Repeat the Kernighan-Lin.

Time Complexity of KL For each pass, O(n2) time to find the best pair to exchange. n pairs exchanged. Total time is O(n3) per pass. Better implementation can get O(n2lg n) time per pass. Number of passes is usually small.