![]() |
displayPURPOSE
Displays a balanced tree.
SYNOPSIS
function display(T,varargin)
DESCRIPTION
Displays a balanced tree. For each node in the tree in prints - For empty leaves: 'Empty Tree'. - For non-empty trees: the data stored in the tree. - For internal tree nodes: the area covered the branch, the split dimension, the split point, and the branch depth. See also BTree. CROSS-REFERENCE INFORMATION
This function calls:
SOURCE CODE
0001 function display(T,varargin) 0002 % Displays a balanced tree. 0003 % 0004 % For each node in the tree in prints 0005 % - For empty leaves: 'Empty Tree'. 0006 % - For non-empty trees: the data stored in the tree. 0007 % - For internal tree nodes: the area covered the branch, the split 0008 % dimension, the split point, and the branch depth. 0009 % 0010 % See also BTree. 0011 0012 if nargin==1 0013 h=' '; 0014 c=T.root; 0015 else 0016 h=varargin{1}; 0017 c=varargin{2}; 0018 end 0019 if c==0 0020 fprintf('%sEmpty Tree\n',h); 0021 else 0022 switch T.data{c}.heigth 0023 case 0 0024 fprintf('%sEmpty Tree\n',h); 0025 case 1 0026 e=T.data{c}.element; 0027 fprintf('%s [%f %f %f]\n',h,e(1),e(2),e(3)); 0028 otherwise 0029 r=T.data{c}.element; 0030 if isa(r,'double') 0031 fprintf('%s[%f %f] [%f %f] [%f %f] (h:%u)\n',h,... 0032 Lower(r(1)),Upper(r(1)),Lower(r(2)),Upper(r(2)),Lower(r(3)),Upper(r(3)),... 0033 T.data{c}.heigth); 0034 else 0035 fprintf('%s',h);display(r);fprintf('(h:%u)\n',T.data{c}.heigth); 0036 end 0037 0038 display(T,[h ' '],T.data{c}.left); 0039 display(T,[h ' '],T.data{c}.right); 0040 end 0041 end |