class documentation

class Dendrogram(object): (source)

Constructor: Dendrogram(items)

View In Hierarchy

Represents a dendrogram, a tree with a specified branching order. This must be initialised with the leaf items, then iteratively call merge for each branch. This class constructs a tree representing the order of calls to the merge function.

Method __init__ No summary
Method __repr__ Undocumented
Method groups Finds the n-groups of items (leaves) reachable from a cut at depth n. :param n: number of groups :type n: int
Method merge Merges nodes at given indices in the dendrogram. The nodes will be combined which then replaces the first node specified. All other nodes involved in the merge will be removed.
Method show Print the dendrogram in ASCII art to standard out. :param leaf_labels: an optional list of strings to use for labeling the
Instance Variable _items Undocumented
Instance Variable _merge Undocumented
Instance Variable _original_items Undocumented
def __init__(self, items=[]): (source)
Parameters
items:sequence of (any)the items at the leaves of the dendrogram
def __repr__(self): (source)

Undocumented

def groups(self, n): (source)

Finds the n-groups of items (leaves) reachable from a cut at depth n. :param n: number of groups :type n: int

def merge(self, *indices): (source)

Merges nodes at given indices in the dendrogram. The nodes will be combined which then replaces the first node specified. All other nodes involved in the merge will be removed.

Parameters
*indices:seq of intindices of the items to merge (at least two)
def show(self, leaf_labels=[]): (source)

Print the dendrogram in ASCII art to standard out. :param leaf_labels: an optional list of strings to use for labeling the

leaves
Parameters
leaf_labels:listUndocumented

Undocumented

_merge: int = (source)

Undocumented

_original_items = (source)

Undocumented