home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 3.ddi / DEMOS.DI$ / HIGHLIGH.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  961 b   |  44 lines

  1. function highlight(A,xy,sep)
  2. %HIGHLIGHT    Plot a mesh with subgraph highlighted.
  3. %    highlight(A,xy,sep) plots a picture of the mesh A with
  4. %    coordinates xy, highlighting the subgraph induced
  5. %    by the vertices in sep.
  6.  
  7. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  8.  
  9. [n,n] = size(A);
  10. [i,j] = find(A);
  11.  
  12. % Plot main graph with vertices before edges.
  13.  
  14. [ignore, p] = sort(max(i,j));
  15. i = i(p);
  16. j = j(p);
  17. X = [ xy(i,1) xy(j,1) NaN*ones(size(i))]';
  18. Y = [ xy(i,2) xy(j,2) NaN*ones(size(i))]';
  19. d = 'r-';
  20. xymin = min(xy);
  21. xymax = max(xy);
  22. range = max(xymax-xymin);
  23. plot (X(:), Y(:), d);
  24. axis([xymin(1) xymin(1)+range xymin(2) xymin(2)+range]);
  25. axis('square');
  26. hold on;
  27.  
  28. % Highlight sep set.
  29.  
  30. B = A(sep,sep);
  31. xB = xy(sep,1);
  32. yB = xy(sep,2);
  33. [i,j] = find(B);
  34. X = [xB(i) xB(j) NaN*ones(size(i))]';
  35. Y = [yB(i) yB(j) NaN*ones(size(i))]';
  36. plot (X(:), Y(:), 'w-');
  37. if n < 1200
  38.    plot(xB,yB,'wo');
  39. else
  40.    plot(xB,yB,'w.');
  41. end
  42.  
  43. hold off;
  44.