Graph Partitioning Algorithms: CME342 - Parallel Methods in Numerical Analysis
Graph Partitioning Algorithms: CME342 - Parallel Methods in Numerical Analysis
1) L given by a*(x-xbar)+b*(y-ybar)=0,
with a2+b2=1; (a,b) is unit vector ⊥ to L
2) For each nj = (xj,yj), compute coordinate
Sj = -b*(xj-xbar) + a*(yj-ybar) along L
3) Let Sbar = median(S1,…,Sn)
4) Let nodes with Sj < Sbar be in N1, rest in N2
• Remains to choose L
Inertial Partitioning: Choosing L
• Clearly prefer L on left below
= a2 * X1 + 2*a*b* X2 + b2 * X3
= [a b] * X1 X2 * a
X2 X3 b
Minimized by choosing
(xbar , ybar) = (Σj xj , Σj yj) / N = center of mass
(a,b) = eigenvector of smallest eigenvalue of X1 X2
X2 X3
Inertial Partitioning: Three Dimensions
• In 3D, the situation is almost identical only that the line
separating the partitions is now a plane, and the vectors and
points have three components.
• The matrix problem is simply 3x3, but conclusions are the
same:
– Choose plane that contains the center of mass of the graph, and
– Has normal vector given by the eigenvector of the 3x3 eigenvalue
problem
• Repeat recursively
Partitioning with Nodal Coordinates - Summary
• Other algorithms and variations are available (random spheres, etc.)
• Algorithms are efficient
• Rely on graphs having nodes connected (mostly) to “nearest neighbors”
in space
– algorithm does not depend on where actual edges are!
• Common when graph arises from physical model
• Can be used as good starting guess for subsequent partitioners, which do
examine edges
• Can do poorly if graph less connected:
Partitioning without Nodal Coordinates-
Breadth First Search (BFS)
• Given G(N,E) and a root node r in N, BFS produces
– A subgraph T of G (same nodes, subset of edges)
– T is a tree rooted at r
– Each node assigned a level = distance from r
Breadth First Search
• Queue (First In First Out, or FIFO)
– Enqueue(x,Q) adds x to back of Q
– x = Dequeue(Q) removes x from front of Q
• Compute Tree T(NT,ET)
• One pass greedily computes |N|/2 possible X and Y to swap, picks best
Comments on Kernighan/Lin Algorithm
(5)
“V - cycle:”
(2,3) (4)
(5)
let Em be empty
mark all nodes in N as unmatched
for i = 1 to |N| … visit the nodes in any order
if i has not been matched
if there is an edge e=(i,j) where j is also unmatched,
add e to Em
mark i and j as matched
endif
endif
endfor
Maximal Matching - Example
Maximal matching
given by red edges:
If there are multiple edges connecting two nodes in Nc, collapse them,
adding edge weights
Example of Coarsening
Example of Coarsening
Expanding a partition of Gc
to a partition of G
Multilevel Spectral Bisection
• Coarsen graph and expand partition using
maximal independent sets
• Improve partition using Rayleigh Quotient
Iteration
Maximal Independent Sets
• Definition: An independent set of a graph G(N,E) is a subset Ni of N
such that no two nodes in Ni are connected by an edge
• Definition: A maximal independent set of a graph G(N,E) is an
independent set Ni to which no more nodes can be added and remain
an independent set
• A simple greedy algorithm computes a maximal independent set:
let Ni be empty
for i = 1 to |N| … visit the nodes in any order
if node i is not adjacent to any node already in Ni
add i to Ni
endif
endfor
Coarsening using Maximal Independent Sets
… Build “domains” D(i) around each node i in Ni to get nodes in Nc
… Add an edge to Ec whenever it would connect two such domains
Ec = empty set
for all nodes i in Ni
D(i) = ( {i}, empty set )
… first set contains nodes in D(i), second set contains edges in D(i)
unmark all edges in E
repeat
choose an unmarked edge e = (i,j) from E
if exactly one of i and j (say i) is in some D(k)
mark e
add j and e to D(k)
else if i and j are in two different D(k)’s (say D(ki) and D(kj))
mark e
add edge (ki, kj) to Ec
else if both i and j are in the same D(k)
mark e
add e to D(k)
else
leave e unmarked
endif
until no unmarked edges
Available Implementations
• Multilevel Kernighan/Lin
– METIS (www.cs.umn.edu/~metis)
– ParMETIS - parallel version
• Multilevel Spectral Bisection
– S. Barnard and H. Simon, “A fast multilevel
implementation of recursive spectral bisection …”, Proc.
6th SIAM Conf. On Parallel Processing, 1993
– Chaco (www.cs.sandia.gov/CRF/papers_chaco.html)
• Hybrids possible
– Ex: Using Kernighan/Lin to improve a partition from
spectral bisection
Available Implementations
• Multilevel Kernighan/Lin
– Demonstrated in experience to be the most efficient
algorithm available.
• Multilevel Spectral Bisection
– Gives good partitions but cost is higher than multilevel K/
L
• Hybrids possible
– For example: Using Kernighan/Lin to improve a partition
from spectral bisection