def format(self, format='newick'):
    'Formats the dendrogram in a foreign format.\n\n        Currently only the Newick format is supported.\n\n        Example:\n\n            >>> d = Dendrogram([(2, 3), (0, 1), (4, 5)])\n            >>> d.format()\n            \'((2,3)4,(0,1)5)6;\'\n            >>> d.names = list("ABCDEFG")\n            >>> d.format()\n            \'((C,D)E,(A,B)F)G;\'\n        '
    if (format == 'newick'):
        n = (self._nitems + self._nmerges)
        if (self._names is None):
            nodes = range(n)
        else:
            nodes = list(self._names)
        if (len(nodes) < n):
            nodes.extend(('' for _ in xrange((n - len(nodes)))))
        for (k, (i, j)) in enumerate(self._merges, self._nitems):
            nodes[k] = ('(%s,%s)%s' % (nodes[i], nodes[j], nodes[k]))
            nodes[i] = nodes[j] = None
        return (nodes[(- 1)] + ';')
    raise ValueError(('unsupported format: %r' % format))
Formats the dendrogram in a foreign format.

Currently only the Newick format is supported.

Example:

    >>> d = Dendrogram([(2, 3), (0, 1), (4, 5)])
    >>> d.format()
    '((2,3)4,(0,1)5)6;'
    >>> d.names = list("ABCDEFG")
    >>> d.format()
    '((C,D)E,(A,B)F)G;'
def format(self, format='newick'):
    'Formats the dendrogram in a foreign format.\n\n        Currently only the Newick format is supported.\n\n        Example:\n\n            >>> d = Dendrogram([(2, 3), (0, 1), (4, 5)])\n            >>> d.format()\n            \'((2,3)4,(0,1)5)6;\'\n            >>> d.names = list("ABCDEFG")\n            >>> d.format()\n            \'((C,D)E,(A,B)F)G;\'\n        '
    if (format == 'newick'):
        n = (self._nitems + self._nmerges)
        if (self._names is None):
            nodes = range(n)
        else:
            nodes = list(self._names)
        if (len(nodes) < n):
            nodes.extend(( for _ in xrange((n - len(nodes)))))
        for (k, (i, j)) in enumerate(self._merges, self._nitems):
            nodes[k] = ('(%s,%s)%s' % (nodes[i], nodes[j], nodes[k]))
            nodes[i] = nodes[j] = None
        return (nodes[(- 1)] + ';')
    raise ValueError(('unsupported format: %r' % format))