FormationControlSimulation/SOURCE/networks-toolbox/selfLoops.m

11 lines
289 B
Matlab
Raw Normal View History

2019-06-17 14:31:50 +07:00
% Count the number of self-loops in the graph
%
% INPUT: adjacency matrix, nxn
% OUTPUT: integer, number of self-loops
%
% Note: in the adjacency matrix representation loops appear as non-zeros on the diagonal
% GB: last updated, Sep 20 2012
function sl=selfLoops(adj)
sl=sum(diag(adj));