-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsimpleTest.m
More file actions
46 lines (31 loc) · 1.07 KB
/
simpleTest.m
File metadata and controls
46 lines (31 loc) · 1.07 KB
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
fr = [1 2 3 4 4 4 5 6 6 7 8 9];
to = [2 1 2 3 5 6 4 4 7 6 7 8];
n = max([fr to]);
nodes = 1:n;
a = sparse(fr,to,1,n,n)
% 0 1 0 0 0 0 0 0 0
% 1 0 0 0 0 0 0 0 0
% 0 1 0 0 0 0 0 0 0
% 0 0 1 0 1 1 0 0 0
% 0 0 0 1 0 0 0 0 0
% 0 0 0 1 0 0 1 0 0
% 0 0 0 0 0 1 0 0 0
% 0 0 0 0 0 0 1 0 0
% 0 0 0 0 0 0 0 1 0
%[n2,a2,b2,c2] = simplifyAM([1:8; 1:8]',a,a);
view(biograph(a))
in = full(sum(a))
out = full(sum(a'))
% Node indices with one in one out
oioo = find(and(in==1,out==1))
% Node indices with two in two out
tito = find(and(in==2,out==2))
succ = @(DAM,n) find(adj(n,:));
pred = @(DAM,n) find(adj(:,n));
neig = @(DAM,n) unique([succ(adj,n) pred(adj,n)']);
removal = []
for i = oioo
if succ(i) ~= pred(i)
removal = [removal i];
end
end