Dendrogram to a directed graph/tree

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?

Upvotes: 0

Views: 172

Answers (1)

sun_is_bright
sun_is_bright

Reputation: 1

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.

Upvotes: 0

Related Questions