-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththesis_nesdisred_example1_figures.m
73 lines (57 loc) · 1.69 KB
/
thesis_nesdisred_example1_figures.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
65
66
67
68
69
70
71
72
73
close all;
get_filename = @(s) ['exports/nesdisred_example1/' s];
N = 4;
Z1 = zeros(N, N);
mkdir('exports/nesdisred_example1')
% Adjacency matrix
A1 = sign(conv2(eye(N), ones(2),'same')) - eye(N);
A = [A1, Z1, ones(N, 1);
Z1, A1, ones(N, 1);
ones(1, 2*N) 0];
% Conductance matrix
G1 = -sign(conv2(eye(N), ones(2),'same')) + eye(N);
G1(1:N+1:end) = -sum(G1) + 1;
G = [G1, Z1, -ones(N, 1);
Z1, G1, -ones(N, 1);
-ones(1, 2*N) 2*N];
is_ext_node = [repmat([0, 1, 1, 0], [1, N/2]) 0]';
%input problem
dotfiles.dump(get_filename('graph_full.dot'), G, is_ext_node);
graphviz.run_neato(get_filename('graph_full.dot'), '-Gstart=5');
% separation tree
[c, cp, cmember] = nesdis(G, 'sym', [N+1 0 1 0]);
f = figure;
draw_cp_tree(cp, cmember);
xlabel('');
set(f, 'Position', [100, 100, 600, 200])
set(f,'PaperPositionMode','auto')
print(get_filename('tree'), '-deps')
close(f);
% what happens when separator is removed
to_keep = 1:8;
to_remove = 9;
G11 = G(to_keep, to_keep);
G12 = G(to_keep, to_remove);
G22 = G(to_remove, to_remove);
Gnosep = G11-(G12*(G22\(G12')));
dotfiles.dump(get_filename('graph_nosep.dot'), Gnosep, is_ext_node(to_keep));
graphviz.run_neato(get_filename('graph_nosep.dot'), '-Gstart=5 -Gsplines=1');
% remove both leafs
sel = [1:4 9];
GL = G(sel, sel)
GL(5, 5) = GL(5,5) - 4;
to_keep = [2 3 5];
to_remove = [1, 4];
G11 = GL(to_keep, to_keep);
G12 = GL(to_keep, to_remove);
G22 = GL(to_remove, to_remove);
GLR = G11-(G12*(G22\(G12')))
% separation tree for case 2
[c, cp, cmember] = nesdis(G, 'sym', [N-1 0 1 0]);
f = figure;
draw_cp_tree(cp, cmember);
xlabel('');
set(f,'PaperPositionMode','auto')
set(f, 'Position', [100, 100, 700, 200])
print(get_filename('tree2'), '-deps')
close(f);