Returns the root nodes in a hierarchical clustering.

Returns the root nodes in a hierarchical clustering corresponding to a cut defined by a flat cluster assignment vector T. See the fcluster function for more information on the format of T.

For each flat cluster $$j$$ of the $$k$$ flat clusters represented in the n-sized flat cluster assignment vector T, this function finds the lowest cluster node $$i$$ in the linkage tree Z such that:

• leaf descendents belong only to flat cluster j (i.e. T[p]==j for all $$p$$ in $$S(i)$$ where $$S(i)$$ is the set of leaf ids of leaf nodes descendent with cluster node $$i$$)
• there does not exist a leaf that is not descendent with $$i$$ that also belongs to cluster $$j$$ (i.e. T[q]!=j for all $$q$$ not in $$S(i)$$). If this condition is violated, T is not a valid cluster assignment vector, and an exception will be thrown.