0001 function netWrite(net, netFile)
0002
0003
0004
0005
0006
0007 if nargin<1, selfdemo; return; end
0008
0009
0010 fid=fopen(netFile, 'w');
0011 if fid<0
0012 error(sprintf('Cannot open %s!', netFile));
0013 end
0014
0015
0016 fprintf(fid, 'VERSION=1.0 (by netWrite.m)\r\n');
0017 fprintf(fid, 'N=%d\tL=%d\r\n', net.nodeNum, net.linkNum);
0018 for i=1:net.nodeNum
0019 fprintf(fid, 'I=%d\tW=%s\r\n', i-1, net.node(i).name);
0020 end
0021
0022 linkIndex=0;
0023 for i=1:net.nodeNum
0024 fanOutNum=length(net.node(i).fanOut);
0025 for j=1:fanOutNum
0026 fprintf(fid, 'J=%d\tS=%d\tE=%d\r\n', linkIndex, i-1, net.node(i).fanOut(j)-1);
0027 linkIndex=linkIndex+1;
0028 end
0029 end
0030 fclose(fid);
0031
0032
0033 function selfdemo
0034 dictFile='test.dic';
0035 fprintf('Reading "%s".\n', dictFile);
0036 dict=dictRead(dictFile);
0037 net=dict2fsdNet(dict);
0038 netFile='test.net';
0039 feval(mfilename, net, netFile);
0040 fprintf('Generated "%s".\n', netFile);