countIOPassNode

PURPOSE ^

COUNTIOPASSNODE count number of passed nodes, new nodes within pathway in specific levels

SYNOPSIS ^

function [nPassNodeInLv, nNewPassNodeInLv, nCumNodeInLv] = countIOPassNode(network, nLevel)

DESCRIPTION ^

 COUNTIOPASSNODE count number of passed nodes, new nodes within pathway in specific levels

   [nPassNodeInLv, nNewPassNodeInLv, nCumNodeInLv] = countIOPassNode(network, nLevel)
   This function count number of passed nodes, new nodes and cumulative nodes
   within input-ouput pair pathway in different levels.
   NOTE: This function may take several hours to analyse.

   Input:
       network: input network
       nLevel: max level to analyse

   Output:
       nPassNodeInLv: cell array containing number of passed nodes in different
           propation levels
       nNewPassNodeInLv: cell array containing number of new nodes in different
           propation levels
       nCumNodeInLv: cell array containing number of cumulative nodes in
           different propation levels

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [nPassNodeInLv, nNewPassNodeInLv, nCumNodeInLv] = countIOPassNode(network, nLevel)
0002 % COUNTIOPASSNODE count number of passed nodes, new nodes within pathway in specific levels
0003 %
0004 %   [nPassNodeInLv, nNewPassNodeInLv, nCumNodeInLv] = countIOPassNode(network, nLevel)
0005 %   This function count number of passed nodes, new nodes and cumulative nodes
0006 %   within input-ouput pair pathway in different levels.
0007 %   NOTE: This function may take several hours to analyse.
0008 %
0009 %   Input:
0010 %       network: input network
0011 %       nLevel: max level to analyse
0012 %
0013 %   Output:
0014 %       nPassNodeInLv: cell array containing number of passed nodes in different
0015 %           propation levels
0016 %       nNewPassNodeInLv: cell array containing number of new nodes in different
0017 %           propation levels
0018 %       nCumNodeInLv: cell array containing number of cumulative nodes in
0019 %           different propation levels
0020 
0021 %   ---------
0022 %   Yen-Nan Lin, NTHU, 2010-2014, Matlab 2012a
0023 
0024 connectMat = network.matrix;
0025 connectMat = single(full(connectMat));
0026 [nRow, nCol] = size(connectMat);
0027 nInput = network.inputNumber;
0028 nOutput = network.outputNumber;
0029 inputIx = 1:nInput;
0030 outputIx = (nInput + 1):(nInput + nOutput);
0031 
0032 connectIxEachCol = cell(1, nCol);
0033 for iCol = 1:nCol
0034     connectIxEachCol{iCol} = single(find(connectMat(:, iCol) > 0));
0035 end
0036 
0037 preLevelMat = eye(nRow, nCol);
0038 preLvPassNode = cell(nRow, nCol);
0039 cumNodeInLv{1} = preLvPassNode;
0040 
0041 for iLevel = 1:nLevel
0042     thisLvPassNode = cell(nRow, nCol);
0043     for jRow = 1:nRow
0044         sourceIxEachRow{jRow} = single(find(preLevelMat(jRow, :) > 0));
0045     end
0046 
0047     for jRow = inputIx
0048         for kCol = 1:nCol
0049             pathList = intersect(sourceIxEachRow{jRow}, connectIxEachCol{kCol});
0050             if ~isempty(pathList)
0051                 pathList = union(pathList, kCol);
0052             end
0053 
0054             thisLvPassNode{jRow, kCol} = ...
0055                 union(pathList, [preLvPassNode{jRow, pathList}]);
0056             if iLevel == 1
0057                 newPassNodeInLv{iLevel}{jRow, kCol} = setdiff( ...
0058                     thisLvPassNode{jRow, kCol}, cumNodeInLv{1}{jRow, kCol});
0059                 cumNodeInLv{iLevel}{jRow, kCol} = union( ...
0060                     cumNodeInLv{1}{jRow, kCol}, thisLvPassNode{jRow, kCol});
0061             else
0062                 newPassNodeInLv{iLevel}{jRow, kCol} = setdiff( ...
0063                     thisLvPassNode{jRow, kCol}, ...
0064                     cumNodeInLv{iLevel - 1}{jRow, kCol});
0065                 cumNodeInLv{iLevel}{jRow, kCol} = union( ...
0066                     cumNodeInLv{iLevel - 1}{jRow, kCol}, ...
0067                     thisLvPassNode{jRow, kCol});
0068             end
0069         end
0070     end
0071     passNodeInLv{iLevel} = thisLvPassNode;
0072     preLvPassNode = thisLvPassNode;
0073     preLevelMat = preLevelMat * connectMat;
0074 
0075     nPassNodeInLv{iLevel} = ...
0076         single(cellfun(@numel, passNodeInLv{iLevel}(inputIx, outputIx)));
0077     nNewPassNodeInLv{iLevel} = ...
0078         single(cellfun(@numel, newPassNodeInLv{iLevel}(inputIx, outputIx)));
0079     nCumNodeInLv{iLevel} = ...
0080         single(cellfun(@numel, cumNodeInLv{iLevel}(inputIx, outputIx)));
0081 end
0082 end

Generated on Thu 30-Jan-2014 00:00:07 by m2html © 2005