-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_test_tree_balanced.m
47 lines (33 loc) · 1.1 KB
/
gen_test_tree_balanced.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
function [V E] = gen_test_tree_balanced(m,h)
%gen_test_tree_balanced Generates test tree
% Detailed explanation goes here
for i = h:-1:1
lev_cnt(i) = m^(i-1);
end
n = sum(lev_cnt);
V = ones(1,n);
E = false(n);
lev_finish = cumsum(lev_cnt);
lev_start = lev_finish - lev_cnt + ones(1,h);
for i = 2:h
for j = 0:lev_cnt(h)-1
child = lev_start(i) + j;
parent = lev_start(i-1) + floor(j/m);
E(child,parent) = 1;
end
end
E = (E + E');
if ([m h] == [1 1]), disp('Corr ECP 1/1 :0');
elseif ([m h] == [1 2]), disp('Corr ECP 1/2 :1 0 0');
elseif ([m h] == [1 3]), disp('Corr ECP 1/3 :');
elseif ([m h] == [2 1]), disp('Corr ECP 2/1 :0');
elseif ([m h] == [2 2]), disp('Corr ECP 2/2 :');
elseif ([m h] == [2 3]), disp('Corr ECP 2/3 :');
elseif ([m h] == [3 1]), disp('Corr ECP 3/1 :0');
elseif ([m h] == [3 2]), disp('Corr ECP 3/2 :3 3 0 0');
elseif ([m h] == [3 3]), disp('Corr ECP 3/3 :27 18 21 12 0 0');
end
%EDP_correct = [sum(1:(n-1)) -(n-1):-1];
%ECP coeffs: 4 4 7 6 0 0
%disp(strvcat('Correct answer:', strrep(mat2str(EDP_correct),' ',', ')))
end