mdot

PURPOSE ^

MDOT - Export a dependency graph into DOT language

SYNOPSIS ^

function mdot(mmat, dotfile,f)

DESCRIPTION ^

MDOT - Export a dependency graph into DOT language
  MDOT(MMAT, DOTFILE) loads a .mat file generated by M2HTML using option
  ('save','on') and writes an ascii file using the DOT language that can
  be drawn using <dot> or <neato> .
  MDOT(MMAT, DOTFILE,F) builds the graph containing M-file F and its
  neighbors only.
  See the folowing page for more details:
  <http://www.research.att.com/sw/tools/graphviz/>

  Example:
    mdot('m2html.mat','m2html.dot');
    !dot -Tps m2html.dot -o m2html.ps
    !neato -Tps m2html.dot -o m2html.ps

  See also M2HTML

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mdot(mmat, dotfile,f)
0002 %MDOT - Export a dependency graph into DOT language
0003 %  MDOT(MMAT, DOTFILE) loads a .mat file generated by M2HTML using option
0004 %  ('save','on') and writes an ascii file using the DOT language that can
0005 %  be drawn using <dot> or <neato> .
0006 %  MDOT(MMAT, DOTFILE,F) builds the graph containing M-file F and its
0007 %  neighbors only.
0008 %  See the folowing page for more details:
0009 %  <http://www.research.att.com/sw/tools/graphviz/>
0010 %
0011 %  Example:
0012 %    mdot('m2html.mat','m2html.dot');
0013 %    !dot -Tps m2html.dot -o m2html.ps
0014 %    !neato -Tps m2html.dot -o m2html.ps
0015 %
0016 %  See also M2HTML
0017 
0018 %  Copyright (C) 2003 Guillaume Flandin
0019 %  $Revision: 1.0 $Date: 2003/29/04 17:33:43 $
0020 
0021 error(nargchk(2,3,nargin));
0022 
0023 if ischar(mmat)
0024     load(mmat);
0025 elseif iscell(mmat)
0026     hrefs  = mmat{1};
0027     names  = mmat{2};
0028     options = mmat{3};
0029     if nargin == 3, mfiles = mmat{4}; end
0030 else
0031     error('[mdot] Invalid argument: mmat.');
0032 end
0033 
0034 fid = fopen(dotfile,'w');
0035 if fid == -1, error(sprintf('[mdot] Cannot open %s.',dotfile)); end
0036 
0037 fprintf(fid,'/* Created by mdot for Matlab */\n');
0038 fprintf(fid,'digraph m2html {\n');
0039 
0040 if nargin == 2
0041     for i=1:size(hrefs,1)
0042         n = find(hrefs(i,:) == 1);
0043         m{i} = n;
0044         for j=1:length(n)
0045             fprintf(fid,['  ' names{i} ' -> ' names{n(j)} ';\n']);
0046         end
0047     end
0048     %m = unique([m{:}]);
0049     fprintf(fid,'\n');
0050     for i=1:size(hrefs,1)
0051         fprintf(fid,['  ' names{i} ' [URL="' names{i} options.extension '"];\n']);
0052     end
0053 else
0054     i = find(strcmp(f,mfiles));
0055     if length(i) ~= 1
0056         error(sprintf('[mdot] Cannot find %s.',f));
0057     end
0058     n = find(hrefs(i,:) == 1);
0059     for j=1:length(n)
0060         fprintf(fid,['  ' names{i} ' -> ' names{n(j)} ';\n']);
0061     end
0062     m = find(hrefs(:,i) == 1);
0063     for j=1:length(m)
0064         if n(j) ~= i
0065             fprintf(fid,['  ' names{m(j)} ' -> ' names{i} ';\n']);
0066         end
0067     end
0068     n = unique([n(:)' m(:)']);
0069     fprintf(fid,'\n');
0070     for i=1:length(n)
0071         fprintf(fid,['  ' names{n(i)} ' [URL="' names{n(i)} options.extension '"];\n']);
0072     end
0073 end
0074 
0075 fprintf(fid,'}');
0076 
0077 fid = fclose(fid);
0078 if fid == -1, error(sprintf('[mdot] Cannot close %s.',dotfile)); end

Generated on Thu 02-Oct-2003 14:58:51 by m2html © 2003