-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph_tree_root.m
More file actions
executable file
·56 lines (51 loc) · 1.89 KB
/
graph_tree_root.m
File metadata and controls
executable file
·56 lines (51 loc) · 1.89 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
44
45
46
47
48
49
50
51
52
53
54
55
56
classdef graph_tree_root < handle
properties
Children = graph_tree_node.empty
Data = [];
labels = [];
end
methods
function G_out = deep_copy(G_in)
props = properties(G_in);
G_out = feval(metaclass(G_in).Name);
for cur_prop = props'
switch cur_prop{1}
case 'Children'
for i = 1:numel(G_in.Children)
G_out.Children(i) = G_in.Children(i).deep_copy();
end
case {'Parent','next_sibling','prev_sibling'}
continue;
otherwise
G_out.(cur_prop{1}) = G_in.(cur_prop{1});
end
end
end
function bool = is_equivalent_to(G_in,G_out)
props = properties(G_in);
bool = true;
for cur_prop = props'
switch cur_prop{1}
case 'Children'
if numel(G_in.Children)~=numel(G_out.Children)
bool = false;
return
end
for i = 1:numel(G_in.Children)
if ~is_equivalent_to(G_in.Children(i),G_out.Children(i))
bool = false;
return
end
end
case {'Parent','next_sibling','prev_sibling'}
continue;
otherwise
if ~isequal(G_out.(cur_prop{1}),G_in.(cur_prop{1}))
bool = false;
return
end
end
end
end
end
end