**********************************</span>
<span class="comment">% compute children cell array (evaluate who are children for each node)</span>
children = cell(N,1);
leafs = [];
<span class="keyword">for</span> node = [1:N]
  children{node} = find(parent == node);
  <span class="keyword">if</span> isempty(children{node})
    leafs(end+1) = node; <span class="comment">% leafs have no children</span>
  <span class="keyword">end</span>
<span class="keyword">end</span>

<span class="comment">%*******************