def as_clustering(self, n=None):
    'Cuts the dendrogram at the given level and returns a corresponding\n        L{VertexClustering} object.\n\n        @param n: the desired number of clusters. Merges are replayed from the\n          beginning until the membership vector has exactly M{n} distinct elements\n          or until there are no more recorded merges, whichever happens first.\n          If C{None}, the optimal count hint given by the clustering algorithm\n          will be used If the optimal count was not given either, it will be\n          calculated by selecting the level where the modularity is maximal.\n        @return: a new L{VertexClustering} object.\n        '
    if (n is None):
        n = self.optimal_count
    num_elts = self._graph.vcount()
    idgen = UniqueIdGenerator()
    membership = community_to_membership(self._merges, num_elts, (num_elts - n))
    membership = [idgen[m] for m in membership]
    return VertexClustering(self._graph, membership, modularity_params=self._modularity_params)
Cuts the dendrogram at the given level and returns a corresponding
L{VertexClustering} object.

@param n: the desired number of clusters. Merges are replayed from the
  beginning until the membership vector has exactly M{n} distinct elements
  or until there are no more recorded merges, whichever happens first.
  If C{None}, the optimal count hint given by the clustering algorithm
  will be used If the optimal count was not given either, it will be
  calculated by selecting the level where the modularity is maximal.
@return: a new L{VertexClustering} object.
def as_clustering(self, n=None):
    'Cuts the dendrogram at the given level and returns a corresponding\n        L{VertexClustering} object.\n\n        @param n: the desired number of clusters. Merges are replayed from the\n          beginning until the membership vector has exactly M{n} distinct elements\n          or until there are no more recorded merges, whichever happens first.\n          If C{None}, the optimal count hint given by the clustering algorithm\n          will be used If the optimal count was not given either, it will be\n          calculated by selecting the level where the modularity is maximal.\n        @return: a new L{VertexClustering} object.\n        '
    if (n is None):
        n = self.optimal_count
    num_elts = self._graph.vcount()
    idgen = UniqueIdGenerator()
    membership = community_to_membership(self._merges, num_elts, (num_elts - n))
    membership = [idgen[m] for m in membership]
    return VertexClustering(self._graph, membership, modularity_params=self._modularity_params)