(self, n=None)
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.
Cuts the dendrogram at the given level and returns a corresponding
        L{VertexClustering} object.
Cuts the dendrogram at the given level and returns a corresponding L { VertexClustering } object .
def as_clustering(self, n=None):
        """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.
        """
        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
        )
def as_clustering ( self , n = None ) : 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 )