function spreordershow

  List = {'random','west0479','airfoil','bucky'};
  Titles = {
    '1. Input matrix', ...
    'Cholesky for input matrix', ...
    '2. RCM ordering', ...
    'Cholesky after RCM', ...
    '3. AMD ordering', ...
    'Cholesky after AMD', ...
    '4. Column count reordering', ...
    'Cholesky after CCR'};

  MainFig = figure( ...
    'MenuBar', 'none', ...
    'Name', 'Sparse Matrix Reordering Show', ...
    'NumberTitle', 'off', ...
    'DeleteFcn', @MainFigClose, ...
    'Position', [50. 120, 900, 600]);

  corr = [.045, .080, -.070, -.130];

  AxesInput = axes('Position', [0, .55, 1/4, .45] + corr, 'NextPlot','ReplaceChildren');
  title(Titles{1});

  AxesInputChol = axes('Position', [0, 0.1, 1/4, .45] + corr, 'NextPlot','ReplaceChildren');
  title(Titles{2});

  AxesRCM = axes('Position', [1/4, .55, 1/4, .45] + corr, 'NextPlot','ReplaceChildren');
  title(Titles{3});
                                    
  AxesRCMChol = axes('Position', [1/4, 0.1, 1/4, .45] + corr, 'NextPlot','ReplaceChildren');
  title(Titles{4});

  AxesAMD = axes('Position', [2/4, .55, 1/4, .45] + corr, 'NextPlot','ReplaceChildren');
  title(Titles{5});

  AxesAMDChol = axes('Position', [2/4, 0.1, 1/4, .45] + corr, 'NextPlot','ReplaceChildren');
  title(Titles{6});

  AxesCol = axes('Position', [3/4, .55, 1/4, .45] + corr, 'NextPlot','ReplaceChildren');
  title(Titles{7});

  AxesColChol = axes('Position', [3/4, 0.1, 1/4, .45] + corr, 'NextPlot','ReplaceChildren');
  title(Titles{8});


  uicontrol('Style','Text','String','Size','Position',[20,30,60,20], ...
    'HorizontalAlignment','right', 'BackgroundColor', get(MainFig, 'Color'));

  EditSize = uicontrol('Style','Edit','String','1000','Position',[90,30,40,20],...
    'CallBack', @EditSizeCallBack);


  uicontrol('Style','Text','String','Density','Position',[150,30,60,20], ...
    'HorizontalAlignment','right', 'BackgroundColor', get(MainFig, 'Color'));

  EditDensity = uicontrol('Style','Edit','String','0.01','Position',[220,30,40,20],...
    'CallBack', @EditDensityCallBack);


  uicontrol('Style','Text','String','Matrix','Position',[300,30,60,20], ...
    'HorizontalAlignment','right', 'BackgroundColor', get(MainFig, 'Color'));

  ListBox = uicontrol('Style','PopupMenu','String',List,'Position',[370,30,120,20],...
    'CallBack', @ListBoxCallBack);


  Run = uicontrol('Style','PushButton','String','Run','Position',[600,30,60,20],...
    'CallBack', @RunCallBack');
  
  uicontrol('Style','PushButton','String','Close','Position',[700,30,60,20],...
    'CallBack','close');

  TimeFig = 0;
  NNZFig = 0;
  

  function EditSizeCallBack(varargin)
    
    num = str2num(get(EditSize, 'String'));
    if length(num) == 1 & num <= 1000 & num >= 5
      set(EditSize, 'String', num2str(round(num)));
    else
      msgbox('The value should be a number in the range [5, 1000]',...
        'Error','error','modal');
    end  

  end;
    

  function EditDensityCallBack(varargin)
    
    num = str2num(get(EditDensity, 'String'));
    if length(num) == 1 & num <= 1 & num >= 0
    else
      msgbox('The value should be a number in the range [5, 1000]',...
        'Error','error','modal');
    end  

  end;
   

  function ListBoxCallBack(varargin)

    matr = get(ListBox, 'String');
    val = get(ListBox, 'Value');

    switch matr{val}
      case 'random'
        set(EditSize,'Enable','On');
        set(EditDensity,'Enable','On');
      otherwise
        set(EditSize,'Enable','Off');
        set(EditDensity,'Enable','Off');
    end;

  end;


  function RunCallBack(varargin)
    
    n = str2num(get(EditSize, 'String'));
    density = str2num(get(EditDensity, 'String'));

    matr = get(ListBox, 'String');
    val = get(ListBox, 'Value');

    switch matr{val}
       case 'random'
         A = sprandsym(n, density);
         A(1:n+1:n^2) = 3*n*density;
       case 'bucky'
         A = bucky;
         n = length(A);
         A(1:n+1:n^2) = n;
       case 'west0479'
         load('west0479.mat');
         S = west0479;
         n = length(S);
         A = S * S' + speye(n);
       case 'airfoil'
         a = load('airfoil.mat');
         n = max(max(a.i), max(a.j));
         A = sparse(a.i, a.j, -1, n, n);
         A = A + A';
         d = abs(sum(A)) + 1;
         A = A + diag(sparse(d));
    end

    Time = zeros(4, 3);
    NNZ = zeros(4, 1);

    axes(AxesInput);
    spy(A); 
    axes(AxesInputChol);
    tic;
    AC = chol(A);
    time = toc;
    Time(1, 2) = time;
    spy(AC + AC');
    title([Titles{2} '. Time = ' num2str(time)]);
    NNZ(1) = nnz(AC + AC');

    tic;
    perm = symrcm(A);
    AO = A(perm, perm);
    time = toc;
    Time(2, 1) = time;
    axes(AxesRCM);
    spy(AO);
    title([Titles{3} '. Time = ' num2str(time)]);
    axes(AxesRCMChol);
    tic;
    AC = chol(AO);
    time = toc;
    Time(2, 2) = time;
    spy(AC + AC');
    title([Titles{4} '. Time = ' num2str(time)]);
    NNZ(2) = nnz(AC + AC');

    tic;
    perm = symamd(A);
    AO = A(perm, perm);
    time = toc;
    Time(3, 1) = time;
    axes(AxesAMD);
    spy(AO);
    title([Titles{5} '. Time = ' num2str(time)]);
    axes(AxesAMDChol);
    tic;
    AC = chol(AO);
    time = toc;
    Time(3, 2) = time;
    spy(AC + AC');
    title([Titles{6} '. Time = ' num2str(time)]);
    NNZ(3) = nnz(AC + AC');

    tic;
    perm = colperm(A);
    AO = A(perm, perm);
    time = toc;
    Time(4, 1) = time;
    axes(AxesCol);
    spy(AO);
    title([Titles{7} '. Time = ' num2str(time)]);
    axes(AxesColChol);
    tic;
    AC = chol(AO);
    time = toc;
    Time(4, 2) = time;
    spy(AC + AC');
    title([Titles{8} '. Time = ' num2str(time)]);
    NNZ(4) = nnz(AC + AC');


    if TimeFig && ishandle(TimeFig)
      figure(TimeFig);
    else
      TimeFig = figure('MenuBar', 'none', 'Name', 'Time Elapsed', 'NumberTitle', 'off');
    end;

    Time(:, 3) = Time(:, 1) + Time(:, 2);
    bar(Time, 2);
    colormap winter;
    legend({'Reordering', 'Cholessky', 'Total'}, 5);

    if NNZFig && ishandle(NNZFig)
      figure(NNZFig);
    else
      NNZFig = figure('MenuBar', 'none', 'Name', 'NNZ', 'NumberTitle', 'off');
    end;

    bar(NNZ);
    colormap winter;

  end;

  function MainFigClose(varargin)

    if TimeFig && ishandle(TimeFig)
      delete(TimeFig);
    end;
    if NNZFig && ishandle(NNZFig)
      delete(NNZFig);
    end;

  end;

end




