FormationControlSimulation/SOURCE/networks-toolbox/adjL2adj.m

16 lines
385 B
Matlab
Raw Normal View History

2019-06-17 14:31:50 +07:00
% Convert an adjacency list to an adjacency matrix.
%
% INPUTS: adjacency list: length n, where L{i_1}=[j_1,j_2,...]
% OUTPUTS: adjacency matrix nxn
%
% Note: Assume that if node i has no neighbours, then L{i}=[];
% GB: last updated, Sep 25 2012
function adj=adjL2adj(adjL)
adj = zeros(length(adjL));
for i=1:length(adjL)
for j=1:length(adjL{i}); adj(i,adjL{i}(j))=1; end
end