(self, weights=None)
return VertexDendrogram(
            self, merges, optimal_count, modularity_params=dict(weights=weights)
        )
Community structure based on the greedy optimization of modularity.

        This algorithm merges individual nodes into communities in a way that
        greedily maximizes the modularity score of the graph. It can be proven
        that if no merge can increase the current modularity score, the
        algorithm can be stopped since no further increase can be achieved.

        This algorithm is said to run almost in linear time on sparse graphs.

        @param weights: edge attribute name or a list containing edge
          weights
        @return: an appropriate L{VertexDendrogram} object.

        @newfield ref: Reference
        @ref: A Clauset, MEJ Newman and C Moore: Finding community structure
          in very large networks. Phys Rev E 70, 066111 (2004).
Community structure based on the greedy optimization of modularity.
Community structure based on the greedy optimization of modularity .
def community_fastgreedy(self, weights=None):
        """Community structure based on the greedy optimization of modularity.

        This algorithm merges individual nodes into communities in a way that
        greedily maximizes the modularity score of the graph. It can be proven
        that if no merge can increase the current modularity score, the
        algorithm can be stopped since no further increase can be achieved.

        This algorithm is said to run almost in linear time on sparse graphs.

        @param weights: edge attribute name or a list containing edge
          weights
        @return: an appropriate L{VertexDendrogram} object.

        @newfield ref: Reference
        @ref: A Clauset, MEJ Newman and C Moore: Finding community structure
          in very large networks. Phys Rev E 70, 066111 (2004).
        """
        merges, qs = GraphBase.community_fastgreedy(self, weights)

        # qs may be shorter than |V|-1 if we are left with a few separated
        # communities in the end; take this into account
        diff = self.vcount() - len(qs)
        qs.reverse()
        if qs:
            optimal_count = qs.index(max(qs)) + diff + 1
        else:
            optimal_count = diff

        return VertexDendrogram(
            self, merges, optimal_count, modularity_params=dict(weights=weights)
        )
def community_fastgreedy ( self , weights = None ) : merges , qs = GraphBase . community_fastgreedy ( self , weights ) # qs may be shorter than |V|-1 if we are left with a few separated # communities in the end; take this into account diff = self . vcount ( ) - len ( qs ) qs . reverse ( ) if qs : optimal_count = qs . index ( max ( qs ) ) + diff + 1 else : optimal_count = diff return VertexDendrogram ( self , merges , optimal_count , modularity_params = dict ( weights = weights ) )