How to populate all possible hierarchical clusterings from a set of elements?

justin justpark78 at gmail.com
Wed Jan 12 14:09:45 EST 2011


The title sounds too complex, but my question is actually simple.

Suppose I have [1,2,3,4,5], then there are many ways of making
clustering.
Among them, I want to pair up terminals until there is only one left
at the end.
For example, ((((1,2),3),4),5), (1,(2,(3,(4,5)))), or (((1,2),(3,4)),
5) would be legitimate ones.

How do you think can I, using the modules of Python such as itertools
as much as possible, make all possible such clusterings?

Thanks in advance,
Justin.



More information about the Python-list mailing list