This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

MinimumBandwidthOrdering

MinimumBandwidthOrdering[g]
attempts to find a vertex ordering that minimizes the bandwidth of the undirected graph g.
MinimumBandwidthOrdering[m]
attempts to find row and column permutations that minimize the bandwidth of the matrix m.
  • For a graph with vertex ordering f, the bandwidth of the graph is defined as
  • Max{u, v}E |f[u]-f[v]|.
  • For a matrix , the bandwidth is defined as
  • .
  • For a symmetric matrix, the envelope size is defined as
  • which is the sum of the distance from the first element in each row to the diagonal position.
  • treats input graphs as undirected.
  • The following options can be given:
MethodAutomaticmethod to use
RefinementMethodAutomaticmethod used to improve ordering
RecursionMethodNonerecursion method to use
This defines a small graph:
This numbers the vertices using ordering from VertexList:
This finds the bandwidth of the graph with the given ordering:
This finds a vertex ordering that attempts to minimize the bandwidth:
This renumbers the vertices using the minimum bandwidth ordering:
This finds the bandwidth using the vertex ordering given by :
This defines a rectangular matrix:
This finds the row and column ordering that attempts to minimize the bandwidth of the matrix:
Plots of the matrix before and after the ordering show a decrease in bandwidth:
Needs["GraphUtilities`"]
This defines a small graph:
In[2]:=
Click for copyable input
This numbers the vertices using ordering from VertexList:
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=
This finds the bandwidth of the graph with the given ordering:
In[5]:=
Click for copyable input
Out[5]=
This finds a vertex ordering that attempts to minimize the bandwidth:
In[6]:=
Click for copyable input
Out[6]=
This renumbers the vertices using the minimum bandwidth ordering:
In[7]:=
Click for copyable input
Out[7]=
This finds the bandwidth using the vertex ordering given by :
In[8]:=
Click for copyable input
Out[8]=
 
Needs["GraphUtilities`"]
This defines a rectangular matrix:
In[2]:=
Click for copyable input
This finds the row and column ordering that attempts to minimize the bandwidth of the matrix:
In[3]:=
Click for copyable input
Out[3]=
Plots of the matrix before and after the ordering show a decrease in bandwidth:
In[4]:=
Click for copyable input
Out[4]=
This finds orderings of a matrix using the methods and :
The maximum bandwidth given by is smaller; envelope size given by is smaller:
One of the applications of minimum bandwidth ordering is in optimizing cache performance of numerical calculations. For example, in multiplying a sparse matrix with a vector, if the matrix is preordered to minimize the bandwidth, then elements of the vector will not be accessed randomly, thus improving cache performance. Because ordering itself takes time, this improvement in cache performance would be beneficial only if the matrix-vector product operation is to be performed repeatedly many times.
This generates a banded matrix, and then randomly permutes it:
This performs a matrix-vector product 50 times:
This permutes the matrix to minimize the bandwidth, and permutes the vector correspondingly:
This shows that the matrix-vector product now takes less time:
This checks that the answer is the same, subject to a permutation: