1function test_sep 2%TEST_SEP test cs_sep, and compare with Gilbert's meshpart vtxsep 3% (requires MESHPART). 4% 5% Example: 6% test_sep 7% 8% See also: testall 9 10% Copyright 2006-2012, Timothy A. Davis, http://www.suitesparse.com 11 12clear functions 13 14index = ssget ; 15[ignore f] = sort (max (index.nrows, index.ncols)) ; 16 17clf 18 19for k = 1:length(f) 20 21 i = f (k) ; 22 Prob = ssget (i) ; 23 disp (Prob) ; 24 A = spones (Prob.A) ; 25 [m n] = size (A) ; 26 if (m ~= n) 27 A = A'*A ; 28 end 29 30 A = A|A' ; 31 32 p = symrcm (A) ; 33 34 n = size (A,1) ; 35 n2 = fix (n/2) ; 36 a = p (1:n2) ; 37 b = p ((n2+1):n) ; 38 39 clf 40 41 subplot (2,3,1) ; spy (A) ; 42 subplot (2,3,2) ; spy (A (p,p)) ; 43 44 hold on 45 plot ([.5 n2+.5 n2+.5 .5 .5], [.5 .5 n2+.5 n2+.5 .5], 'r', 'LineWidth', 2) ; 46 hold off 47 48 subplot (2,3,3) ; spy (A (a,b)) ; title ('edge sep') ; 49 subplot (2,3,6) ; cs_dmspy (A (a,b)) ; title ('node sep') ; 50 51 [s as bs] = vtxsep (A,a,b) ; %#ok 52 [s2 a2 b2] = cs_sep (A,a,b) ; 53 54 p2 = [a2 b2 s2] ; 55 B = A (p2,p2) ; 56 subplot (2,3,5) ; spy (B) ; 57 hold on 58 59 px = [s2 a2 b2] ; 60 if (any (sort (px) ~= 1:n)) 61 px %#ok 62 n %#ok 63 error ('!') ; 64 end 65 66 na = length (a2) ; 67 nb = length (b2) ; 68 ns = length (s2) ; %#ok 69 70 nab = na + nb ; 71 72 plot ([.5 na+.5 na+.5 .5 .5], [.5 .5 na+.5 na+.5 .5], 'r', 'LineWidth', 2) ; 73 74 plot ([na nab nab na na]+0.5, [na na nab nab na]+0.5, 'r', 'LineWidth', 2) ; 75 76 plot ([.5 nab+.5 nab+.5 .5 .5], [.5 .5 nab+.5 nab+.5 .5], 'g', 'LineWidth', 1) ; 77 78 hold off 79 80 nz1 = nnz (A (a2,b2)) ; 81 if (nz1 ~= 0) 82 nz1 %#ok 83 error ('!') ; 84 end 85 86 nz2 = nnz (A (a2,b2)) ; 87 if (nz2 ~= 0) 88 nz2 %#ok 89 error ('!') ; 90 end 91 92 if (length (s) ~= length (s2)) 93 fprintf ('lengths differ: %d %d\n', length (s), length (s2)) ; 94 end 95 96 drawnow 97 % pause 98 99 100end 101