Dendrogram to a directed graph/tree

65 Views Asked by At

I am trying to convert a dendrogram into a graph/tree to perform calculations with its nodes, leaves and subtrees and find a miximal subgraphs, but I have not found a function/package that helps me in this process

i was trying to convert the dendogram to a 'newick' format, but im not sure if it is the better way.

I created the dendogram with 'scipy.cluster.hierarchy' pakege

Any ideas?

1

There are 1 best solutions below

0
sun_is_bright On

Witht the .to_tree function you can convert the linkage matrix returned as Z in your code to a tree object.

tree_Z = hierarchy.to_tree(Z)

This gives you an ClusterNode Tree object which you can traverse.