Hi,I'm trying to implement a custom ordering of a dendrogram (obtained using the linkage function) based on the rule that the "highest" branch has to be always on the right side. As an example:
%generate a tree using linkage
rng('default'); %for reproducibility
X = rand(10,2);D = pdist(X);tree = linkage(D,'average');%my desired order
myOrd = [1,4,5,8,9,2,10,3,6,7];%plot
figure();subplot(2,1,1); dendrogram(tree); title('Default leaf order');subplot(2,1,2); dendrogram(tree,'Reorder',myOrd); title('Desired leaf order');
Do you have any idea for a more efficient implementation?
Thank you
Best Answer