[AuxContactMatrix] = ConvertFromIndex(indexmatrix,one_gen) ConvertFromIndex: Transforms a vector of indices corresponding to edges in an adjacency matrix. INPUT indexmatrix : Matrix in which cell i,j contains the index of the edge one_gen: One vector where each position i corresponds to absence/presence of edge represented by index i in the structure OUTPUT AuxContactMatrix: Adjacency matrix Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
0001 function[AuxContactMatrix] = ConvertFromIndex(indexmatrix,one_gen) 0002 % [AuxContactMatrix] = ConvertFromIndex(indexmatrix,one_gen) 0003 % 0004 % ConvertFromIndex: Transforms a vector of indices corresponding to edges in an adjacency 0005 % matrix. 0006 % INPUT 0007 % indexmatrix : Matrix in which cell i,j contains the index of the edge 0008 % one_gen: One vector where each position i corresponds to absence/presence 0009 % of edge represented by index i in the structure 0010 % OUTPUT 0011 % AuxContactMatrix: Adjacency matrix 0012 % 0013 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es) 0014 0015 n = size(indexmatrix,1); % number of variables 0016 0017 alledges = find(one_gen>0); % edges present in the structure 0018 0019 AuxContactMatrix = zeros(n,n); 0020 0021 for i=1:size(alledges,1) 0022 [row,col] = find(indexmatrix==alledges(i)); 0023 AuxContactMatrix(row,col) = one_gen(alledges(i)); 0024 end