forked from lrvarshney/elegans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conncomp_gap.m
64 lines (56 loc) · 1.62 KB
/
conncomp_gap.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function conncomp_gap(varargin)
%CONNCOMP_GAP Lists the connected components for the gap junction network.
% CONNCOMP_GAP produces a listing of the connected components of the gap
% junction network.
%
% CONNCOMP_GAP(A,L) produces a listing of connected components of an
% undirected network with adjacency matrix A and node labels L.
%
% See also GRAPHCONNCOMP, CONNCOMP_CHEM.
% Copyright 2006-2009. Lav R. Varshney
%
% This software is provided without warranty.
% Related article:
%
% L. R. Varshney, B. L. Chen, E. Paniagua, D. H. Hall, and D. B.
% Chklovskii, "Structural properties of the Caenorhabditis elegans
% neuronal network," 2009, in preparation.
if (nargin == 0)
%load the gap junction network
[A,labels] = datareader('gap','unweighted');
elseif (nargin == 2)
A = varargin{1};
labels = varargin{2};
else
error('CONNCOMP_GAP: incorrect number of inputs');
end
%compute connected components
[S,C] = graphconncomp(A);
%list the giant component
gc = mode(C);
giantcomp = find(C == gc);
disp('Giant Component')
for ii = 1:length(giantcomp)
disp(labels(giantcomp(ii)));
end
%list the smaller components
n = hist(C,S);
zz = 2;
for ii = 1:S
if (n(ii) > 1 ) && (ii ~= gc)
disp(strcat('Component ',num2str(zz)));
component = find(C == ii);
for jj = 1:n(ii)
disp(labels(component(jj)));
end
zz = zz + 1;
end
end
%list the unconnected neurons
disp('Unconnected')
for ii = 1:S
if (n(ii) == 1)
component = find(C == ii);
disp(labels(component));
end
end