1function dg(A) 2%DG order and plot A*A', using CHOLMOD's nested dissection 3% used by test27.m 4% Example: 5% dg(A) 6% See also cholmod_test 7 8% Copyright 2007, Timothy A. Davis, http://www.suitesparse.com 9 10A = GB_spones_mex (A) ; 11[p cp cm] = nesdis (A, 'row') ; 12 13% get the corresponding column ordering. Order the columns 14% in increasing order of min(find(A(:,j))) 15 16[m n] = size (A) ; 17C = A (p,:) ; 18qmin = zeros (1,n) ; 19for j = 1:n 20 qmin (j) = min (find (C (:,j))) ; %#ok 21end 22[ignore q] = sort (qmin) ; 23 24C = C (:,q) ; 25clf 26subplot (2,3,1) ; treeplot (cp) 27drawnow 28subplot (2,3,2) ; spy (C) 29drawnow 30% axis off 31subplot (2,3,3) ; spy (C*C') 32drawnow 33% axis off 34 35ncomp = max(cm) ; 36fprintf ('# of components: %d\n', ncomp) 37 38% cs = [cm(p) n+1] ; 39% cboundaries = find (diff (cs)) ; 40 41fprintf ('size of root %d out of %d rows\n', length (find (cm == ncomp)), m); 42 43[cnt h pa po R] = symbfact2 (A (p,:), 'row') ; 44% rc = full (sum (R)) ; 45 46for k = 1:ncomp 47 fprintf ('node %4d : parent %4d size %6d work %g\n', ... 48 k, cp (k), length (find (cm == k)), sum (cnt (find (cm == k)).^2) ) ; %#ok 49end 50 51subplot (2,3,4) ; spy (A*A') ; 52drawnow 53 54subplot (2,3,5) ; spy (R+R') ; 55drawnow 56 57pamd = amd2 (A*A') ; % use AMD from SuiteSparse, not built-in 58[cnt h pa po R] = symbfact2 (A (pamd,:), 'row') ; 59subplot (2,3,6) ; spy (R+R') ; 60drawnow 61 62% s = bisect (A, 'row') ; 63% [ignore pp] = sort (s) ; 64% E = A(pp,:) ; 65% subplot (2,3,4) ; spy (E*E') 66% fprintf ('bisect: %d\n', length (find (s == 2))) ; 67 68% spy (C*C') 69% hold on 70% for j = cboundaries 71% plot ([1 n], [j j], 'r', [j j], [1 n], 'r') ; 72% end 73 74 75