-
Notifications
You must be signed in to change notification settings - Fork 5
/
degrees_dir.m
31 lines (26 loc) · 892 Bytes
/
degrees_dir.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function [id,od,deg] = degrees_dir(CIJ)
%DEGREES_DIR Indegree and outdegree
%
% [id,od,deg] = degrees_dir(CIJ);
%
% Node degree is the number of links connected to the node. The indegree
% is the number of inward links and the outdegree is the number of
% outward links.
%
% Input: CIJ, directed (binary/weighted) connection matrix
%
% Output: id, node indegree
% od, node outdegree
% deg, node degree (indegree + outdegree)
%
% Notes: Inputs are assumed to be on the columns of the CIJ matrix.
% Weight information is discarded.
%
%
% Olaf Sporns, Indiana University, 2002/2006/2008
% ensure CIJ is binary...
CIJ = double(CIJ~=0);
% compute degrees
id = sum(CIJ,1); % indegree = column sum of CIJ
od = sum(CIJ,2)'; % outdegree = row sum of CIJ
deg = id+od; % degree = indegree+outdegree