cuthell-mckee
TRANSCRIPT
-
7/31/2019 Cuthell-McKee
1/4
Tutorial: Bandwidth reduction - The CutHill-McKee Algorithm
Posted by Ciprian Zavoianu
1. The problem
I've recently come across an interesting NP-complete problem :D. It's the
bandwidth reduction problem, also known in the field of sparse matrixapplications as the bandwidth minimization problem (or BMP in short):
For a given simetricsparse matrix, M(nxn), the problem is to reduce its
bandwidth B by permuting rows and columns such as to move all the
nonzero elements of M in a band as close as possible to the diagonal.
In other words, the problem consists of transforming through successive row and
column permutations this (8x8 input matrix):
into,possibly, this (8x8 output matrix):
Now here's an interesting thing regarding this problem. If you consider the givensparse matrix (the input matrix) and the resulting matrix (the output matrix) as
adjacency matrices for some given graphs, this is what you end up with:
.The graph associated with the input matrix.
https://profiles.google.com/115435011745187459863http://en.wikipedia.org/wiki/NP-completehttp://en.wikipedia.org/wiki/Sparse_matrixhttp://1.bp.blogspot.com/-PM1QShWvMUI/TmYSwQgwSbI/AAAAAAAAAlw/4FCC8pRKRqA/s1600/Matrix2.jpghttp://4.bp.blogspot.com/-zLjGZI-xqgI/TmYSwA26brI/AAAAAAAAAl0/J3SzEfaAhi0/s1600/Matrix1.jpghttp://en.wikipedia.org/wiki/NP-completehttp://en.wikipedia.org/wiki/Sparse_matrixhttps://profiles.google.com/115435011745187459863 -
7/31/2019 Cuthell-McKee
2/4
The graph associated with the output matrix.
As you can easily see, the two graph structures are identical, the only thing that
is different is the node (vertex) labeling. In other words the bandwidthreduction problem can also be viewed as a graph labeling problem:
Find the node labeling that minimizes the bandwidth B of the adjacency
matrix of the graph G(n) , where we can formally define: B=max|Li-Lj|,i,j=1..n andLiis the label of nodei, Ljis the label of nodejand
nodesi and j are adjacentor neighbours (i.e there is an edge ingraph G(n) connecting nodes iandj).
2. The solution
Back in the 60's and 70's many graph algorithms were proposed for "solving"the
bandwidth reduction problem. I wrote "solving"beacause the problem is after allNP-complete and none of the algorithms described claimed to find the exact
solution(s) regardless of the input matrix, but they were more or less succesfull infinding a relatively good solution in a resonable amount of time (the so called
heuristic approach to NP-complete problem solving)..
Initially the most widely used of these heuristics was the Reverse Cuthill-McKee
algorithm (RCM), a modification by Alan George of the original algorithm developedby CutHill and McKee in 1969. In 1976 the GPS algorithm (named after its
developers Gibbs, Poole and Stockmeyer) was proposed. On average GPS and RCMfind solutions of relative equal quality, but GPS is up to ten times as fast.
One last thing I should remind you before I continue with the description of theRCM algorithm: the degree of a node in a graph is the number of nodes adjacent
to it. So here is the RCM algorithm for a given graph G(n).
http://www.jstor.org/stable/2156090http://2.bp.blogspot.com/-txtK08-4lOM/TmYSv9YwvyI/AAAAAAAAAlg/wmxOre8EXy8/s1600/Graph2.jpghttp://2.bp.blogspot.com/-hECyNpiVpBA/TmYSv7C3tKI/AAAAAAAAAlk/FA2LuB9dzgA/s1600/Graph1.jpghttp://www.jstor.org/stable/2156090 -
7/31/2019 Cuthell-McKee
3/4
Step 0: Prepare an empty queue Q and an empty result array R.Step 1: Select the node in G(n) with the lowest degree (ties are broken
arbitrarily) that hasn't previously been inserted in the result array. Let usname it P(for Parent).
Step 2: Add Pin the first free position ofR.
Step 3: Add to the queue all the nodes adjacent with Pin the increasingorder of their degree.
Step 4.1: Extract the first node from the queue and examine it. Let usname it C(for Child).
Step 4.2: IfChasn't previously been inserted in R, add it in the first free
position and add to Q all the neighbours ofCthat are not in R in theincreasing order of their degree.
Step 5: IfQ is not empty repeat from Step 4.1 .Step 6: If there are unexplored nodes (the graph is not connected)
repeat from Step 1 .
Step 7: Reverse the order of the elements in R. Element R[i] is swapedwith element R[n+1-i].
The result array will be interpreted like this: R[L] = imeans that the newlabel of node i(the one that had the initial label ofi) will be L.
As you can see steps 1-6 describe nothing but a classicBreadth First Search
(BFS) with the minor modification that the nodes are explored in the increasingorder of their degree. Step 7 is not mandatory, it is the modification introduced
by George to the initial algorithm (it has the purpose of further reducing the profileof a matrix, but that is another story). If you don't reverse the result array you
end up with the original Cuthill-McKee algorithm.
Here is how the RCM algorithm should perform on the 8x8 input matrixpresented at the start of this post:
- At first we must choose a starting node. Nodes initially labeled with 1, 4 and 7
are equally good choices as all of them have the degree of 1.- Let us start with node 1. We'll add 1 in R and its neighbours in Q in the
increasing order of their degree: R=[1]; Q=[5];- We extract the first element from Q. As 5isn't in R we add it. We also add all the
neighbours of5, that are not in R, in Q in the increasing order of their degree:
R[1,5]; Q=[3];- We extract the first element from Q. 3 is not in R so we add 3 to R and all the
neighbours of3, that are not in R, to Q in the increasing order of their degree:R=[1,5,3]; Q=[2];
- We extract the first element from Q. 2 is not in R so we add 2 to R and all theneighbours of2, that are not in R, to Q in the increasing order of their degree:
R=[1,5,3,2]; Q=[6,8];
- We extract the first element from Q. 6 is not in R so we add 6 to R and all the
http://en.wikipedia.org/wiki/Breadth-first_searchhttp://en.wikipedia.org/wiki/Breadth-first_search -
7/31/2019 Cuthell-McKee
4/4
neighbours of6, that are not in R, to Q in the increasing order of their degree:R=[1,5,3,2,6]; Q=[8,8];
- We extract the first element from Q. 8 is not in R so we add 8 to R and all the
neighbours of8, that are not in R, to Q in the increasing order of their degree:R=[1,5,3,2,6,8]; Q=[8];
- We extract the first element from Q. 8 is in R so we do nothing:
R=[1,5,3,2,6,8]; Q=[];- Q is empty so we check the size ofR. If the size ofR equals 8 then we are done,
otherwise there are still unexplored nodes (the graph is not connected). As the sizeofR is 6 we must restart from Step 1.
- We must again choose a starting node. Nodes labeled 4 and 7are equally goodstart solutions as they both have a degree of 1.
- We choose node 4. We'll add 4 in R and its neighbours in Q in the increasingorder of their degree: R=[1,5,3,2,6,8,4]; Q=[7];
- We extract the first element from Q. 7is not in R so we add 7to R and all the
neighbours of7, that are not in R, to Q in the increasing order of their degree:R=[1,5,3,2,6,8,4,7]; Q=[];
- Q is empty so we check the size ofR. The size ofR is 8 so all the nodes havebeen relabeled.
- We reverse R and obtain the solution R=[7,4,8,6,2,3,5,1] with the following
interpretation:
If you look closely at the two graph images at the start of the post you can see how
the node which had the initial label of7 will be relabeled with 1, the node whichhad the initial label of4will be relabeled with 2, the node which had the initial
label of8 will be relabeled with 3, and so on.
.The only thing left now is to build the adjacency matrix of the relabeled graph. You
should obtain the 8x8 output matrixpresented at the start of this tutorial.
P.S. For a Delphi implementation (source code included) of the Cuthill-McKee
and RCM algorithms, as well as a comparison of these methods with a moremodern aproach based on a genetic algorithm and simulated annealing
please see this post.
http://ciprian-zavoianu.blogspot.com/2009/01/project-bandwidth-reduction_18.htmlhttp://3.bp.blogspot.com/-fNyhVBRvjrM/TmYSwlrJ7aI/AAAAAAAAAl8/Chq4thuau8M/s1600/Relabeling.jpghttp://ciprian-zavoianu.blogspot.com/2009/01/project-bandwidth-reduction_18.html