@property
def optimal_count(self):
    'Returns the optimal number of clusters for this dendrogram.\n\n        If an optimal count hint was given at construction time, this\n        property simply returns the hint. If such a count was not given,\n        this method calculates the optimal number of clusters by maximizing\n        the modularity along all the possible cuts in the dendrogram.\n        '
    if (self._optimal_count is not None):
        return self._optimal_count
    n = self._graph.vcount()
    (max_q, optimal_count) = (0, 1)
    for step in xrange(min((n - 1), len(self._merges))):
        membs = community_to_membership(self._merges, n, step)
        q = self._graph.modularity(membs, **self._modularity_params)
        if (q > max_q):
            optimal_count = (n - step)
            max_q = q
    self._optimal_count = optimal_count
    return optimal_count
Returns the optimal number of clusters for this dendrogram.

If an optimal count hint was given at construction time, this
property simply returns the hint. If such a count was not given,
this method calculates the optimal number of clusters by maximizing
the modularity along all the possible cuts in the dendrogram.
@property
def optimal_count(self):
    'Returns the optimal number of clusters for this dendrogram.\n\n        If an optimal count hint was given at construction time, this\n        property simply returns the hint. If such a count was not given,\n        this method calculates the optimal number of clusters by maximizing\n        the modularity along all the possible cuts in the dendrogram.\n        '
    if (self._optimal_count is not None):
        return self._optimal_count
    n = self._graph.vcount()
    (max_q, optimal_count) = (0, 1)
    for step in xrange(min((n - 1), len(self._merges))):
        membs = community_to_membership(self._merges, n, step)
        q = self._graph.modularity(membs, **self._modularity_params)
        if (q > max_q):
            optimal_count = (n - step)
            max_q = q
    self._optimal_count = optimal_count
    return optimal_count