class cluster.cluster.Cluster(level, *args)

Bases: object

A collection of items. This is internally used to detect clustered items in the data so we could distinguish other collection types (lists, dicts, …) from the actual clusters. This means that you could also create clusters of lists with this class.


Pretty-prints this cluster. Useful for debuging.


Retrieve all clusters up to a specific level threshold. This level-threshold represents the maximum distance between two clusters. So the lower you set this threshold, the more clusters you will receive and the higher you set it, you will receive less but bigger clusters.

Parameters:threshold – The level threshold:


It is debatable whether the value passed into this method should really be as strongly linked to the real cluster-levels as it is right now. The end-user will not know the range of this value unless s/he first inspects the top-level cluster. So instead you might argue that a value ranging from 0 to 1 might be a more useful approach.


Returns the structure (topology) of the cluster as tuples.

Output from

 <Cluster@0.181818181818(['ChangeLog', 'ChangeLog.txt'])>])>,
 <Cluster@0.647058823529(['', <Cluster@0.625(['.idlerc',

Corresponding output from cl.topo():

('CVS', ('34.xls', (('0.txt', ('ChangeLog', 'ChangeLog.txt')),
('', ('.cvsignore', ('',
('.idlerc', '.pylint.d')))))))