From 909b08932725678b560aad92cbb0460ae1b7953a Mon Sep 17 00:00:00 2001 From: Aaron Ponti Date: Thu, 21 Sep 2017 11:48:12 +0200 Subject: [PATCH 1/2] Add function to return all nodes at branch points. --- @tree/findbranchpoints.m | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 @tree/findbranchpoints.m 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 From 5089bfe44fc2bc019a1efc91d568bec92a6fa0d0 Mon Sep 17 00:00:00 2001 From: Aaron Ponti Date: Mon, 9 Apr 2018 18:13:05 +0200 Subject: [PATCH 2/2] Find will fail if obj.Node cell array contains empty values. --- @tree/find.m | 1 + 1 file changed, 1 insertion(+) 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