def summary(self, verbosity=0, max_leaf_count=40):
    'Returns the summary of the dendrogram.\n\n        The summary includes the number of leafs and branches, and also an\n        ASCII art representation of the dendrogram unless it is too large.\n\n        @param verbosity: determines whether the ASCII representation of the\n          dendrogram should be printed. Zero verbosity prints only the number\n          of leafs and branches.\n        @param max_leaf_count: the maximal number of leafs to print in the\n          ASCII representation. If the dendrogram has more leafs than this\n          limit, the ASCII representation will not be printed even if the\n          verbosity is larger than or equal to 1.\n        @return: the summary of the dendrogram as a string.\n        '
    out = StringIO()
    ((print >> out), ('Dendrogram, %d elements, %d merges' % (self._nitems, self._nmerges)))
    if ((self._nitems == 0) or (verbosity < 1) or (self._nitems > max_leaf_count)):
        return out.getvalue().strip()
    (print >> out)
    positions = ([None] * self._nitems)
    inorder = self._traverse_inorder()
    distance = 2
    level_distance = 2
    nextp = 0
    for (idx, element) in enumerate(inorder):
        positions[element] = nextp
        inorder[idx] = str(element)
        nextp += max(distance, (len(inorder[idx]) + 1))
    width = (max(positions) + 1)
    ((print >> out), (' ' * (distance - 1)).join(inorder))
    midx = 0
    max_community_idx = self._nitems
    while (midx < self._nmerges):
        char_array = ([' '] * width)
        for position in positions:
            if (position >= 0):
                char_array[position] = '|'
        char_str = ''.join(char_array)
        for _ in xrange((level_distance - 1)):
            ((print >> out), char_str)
        cidx_incr = 0
        while (midx < self._nmerges):
            (id1, id2) = self._merges[midx]
            if ((id1 >= max_community_idx) or (id2 >= max_community_idx)):
                break
            midx += 1
            (pos1, pos2) = (positions[id1], positions[id2])
            (positions[id1], positions[id2]) = ((- 1), (- 1))
            if (pos1 > pos2):
                (pos1, pos2) = (pos2, pos1)
            positions.append(((pos1 + pos2) // 2))
            dashes = ('-' * ((pos2 - pos1) - 1))
            char_array[pos1:(pos2 + 1)] = ("`%s'" % dashes)
            cidx_incr += 1
        max_community_idx += cidx_incr
        ((print >> out), ''.join(char_array))
    return out.getvalue().strip()
Returns the summary of the dendrogram.

The summary includes the number of leafs and branches, and also an
ASCII art representation of the dendrogram unless it is too large.

@param verbosity: determines whether the ASCII representation of the
  dendrogram should be printed. Zero verbosity prints only the number
  of leafs and branches.
@param max_leaf_count: the maximal number of leafs to print in the
  ASCII representation. If the dendrogram has more leafs than this
  limit, the ASCII representation will not be printed even if the
  verbosity is larger than or equal to 1.
@return: the summary of the dendrogram as a string.
def summary(self, verbosity=0, max_leaf_count=40):
    'Returns the summary of the dendrogram.\n\n        The summary includes the number of leafs and branches, and also an\n        ASCII art representation of the dendrogram unless it is too large.\n\n        @param verbosity: determines whether the ASCII representation of the\n          dendrogram should be printed. Zero verbosity prints only the number\n          of leafs and branches.\n        @param max_leaf_count: the maximal number of leafs to print in the\n          ASCII representation. If the dendrogram has more leafs than this\n          limit, the ASCII representation will not be printed even if the\n          verbosity is larger than or equal to 1.\n        @return: the summary of the dendrogram as a string.\n        '
    out = StringIO()
    ((print >> out), ('Dendrogram, %d elements, %d merges' % (self._nitems, self._nmerges)))
    if ((self._nitems == 0) or (verbosity < 1) or (self._nitems > max_leaf_count)):
        return out.getvalue().strip()
    (print >> out)
    positions = ([None] * self._nitems)
    inorder = self._traverse_inorder()
    distance = 2
    level_distance = 2
    nextp = 0
    for (idx, element) in enumerate(inorder):
        positions[element] = nextp
        inorder[idx] = str(element)
        nextp += max(distance, (len(inorder[idx]) + 1))
    width = (max(positions) + 1)
    ((print >> out), (' ' * (distance - 1)).join(inorder))
    midx = 0
    max_community_idx = self._nitems
    while (midx < self._nmerges):
        char_array = ([' '] * width)
        for position in positions:
            if (position >= 0):
                char_array[position] = '|'
        char_str = .join(char_array)
        for _ in xrange((level_distance - 1)):
            ((print >> out), char_str)
        cidx_incr = 0
        while (midx < self._nmerges):
            (id1, id2) = self._merges[midx]
            if ((id1 >= max_community_idx) or (id2 >= max_community_idx)):
                break
            midx += 1
            (pos1, pos2) = (positions[id1], positions[id2])
            (positions[id1], positions[id2]) = ((- 1), (- 1))
            if (pos1 > pos2):
                (pos1, pos2) = (pos2, pos1)
            positions.append(((pos1 + pos2) // 2))
            dashes = ('-' * ((pos2 - pos1) - 1))
            char_array[pos1:(pos2 + 1)] = ("`%s'" % dashes)
            cidx_incr += 1
        max_community_idx += cidx_incr
        ((print >> out), .join(char_array))
    return out.getvalue().strip()