diff --git a/@tree/find.m b/@tree/find.m index b8d8d55..f65bf2c 100644 --- a/@tree/find.m +++ b/@tree/find.m @@ -12,6 +12,7 @@ % I = FIND(T,K,'last') returns at most the last K indices corresponding % to the nonzero entries of the tree T. % + obj.Node(cellfun(@isempty, obj.Node)) = {false}; val = [ obj.Node{:} ] ; I = find(val, varargin{:}); end \ No newline at end of file diff --git a/@tree/findbranchpoints.m b/@tree/findbranchpoints.m new file mode 100644 index 0000000..fadd32d --- /dev/null +++ b/@tree/findbranchpoints.m @@ -0,0 +1,11 @@ +function indices = findbranchpoints(obj, varargin) +%FIND Find indices of nodes with more than one child. +% I = FINDBRANCHPOINTS(T) returns the linear indices corresponding to the +% nonzero entries of the tree T. + + indices = find( ... + arrayfun(@(x) numel(obj.getchildren(x)), ... + obj.nodeorderiterator(), ... + 'UniformOutput', true) > 1); + +end \ No newline at end of file