(
        self,
        objective_function="CPM",
        weights=None,
        resolution_parameter=1.0,
        beta=0.01,
        initial_membership=None,
        n_iterations=2,
        node_weights=None,
    )
return VertexClustering(self, membership, modularity_params=modularity_params)
Finds the community structure of the graph using the Leiden
        algorithm of Traag, van Eck & Waltman.

        @param objective_function: whether to use the Constant Potts
          Model (CPM) or modularity. Must be either C{"CPM"} or C{"modularity"}.
        @param weights: edge weights to be used. Can be a sequence or
          iterable or even an edge attribute name.
        @param resolution_parameter: the resolution parameter to use.
          Higher resolutions lead to more smaller communities, while
          lower resolutions lead to fewer larger communities.
        @param beta: parameter affecting the randomness in the Leiden
          algorithm. This affects only the refinement step of the algorithm.
        @param initial_membership: if provided, the Leiden algorithm
          will try to improve this provided membership. If no argument is
          provided, the aglorithm simply starts from the singleton partition.
        @param n_iterations: the number of iterations to iterate the Leiden
          algorithm. Each iteration may improve the partition further. Using
          a negative number of iterations will run until a stable iteration is
          encountered (i.e. the quality was not increased during that
          iteration).
        @param node_weights: the node weights used in the Leiden algorithm.
          If this is not provided, it will be automatically determined on the
          basis of whether you want to use CPM or modularity. If you do provide
          this, please make sure that you understand what you are doing.
        @return: an appropriate L{VertexClustering} object.

        @newfield ref: Reference
        @ref: Traag, V. A., Waltman, L., & van Eck, N. J. (2019). From Louvain
          to Leiden: guaranteeing well-connected communities. Scientific
          reports, 9(1), 5233. doi: 10.1038/s41598-019-41695-z
Finds the community structure of the graph using the Leiden
        algorithm of Traag, van Eck & Waltman.
Finds the community structure of the graph using the Leiden algorithm of Traag van Eck & Waltman .
def community_leiden(
        self,
        objective_function="CPM",
        weights=None,
        resolution_parameter=1.0,
        beta=0.01,
        initial_membership=None,
        n_iterations=2,
        node_weights=None,
    ):
        """Finds the community structure of the graph using the Leiden
        algorithm of Traag, van Eck & Waltman.

        @param objective_function: whether to use the Constant Potts
          Model (CPM) or modularity. Must be either C{"CPM"} or C{"modularity"}.
        @param weights: edge weights to be used. Can be a sequence or
          iterable or even an edge attribute name.
        @param resolution_parameter: the resolution parameter to use.
          Higher resolutions lead to more smaller communities, while
          lower resolutions lead to fewer larger communities.
        @param beta: parameter affecting the randomness in the Leiden
          algorithm. This affects only the refinement step of the algorithm.
        @param initial_membership: if provided, the Leiden algorithm
          will try to improve this provided membership. If no argument is
          provided, the aglorithm simply starts from the singleton partition.
        @param n_iterations: the number of iterations to iterate the Leiden
          algorithm. Each iteration may improve the partition further. Using
          a negative number of iterations will run until a stable iteration is
          encountered (i.e. the quality was not increased during that
          iteration).
        @param node_weights: the node weights used in the Leiden algorithm.
          If this is not provided, it will be automatically determined on the
          basis of whether you want to use CPM or modularity. If you do provide
          this, please make sure that you understand what you are doing.
        @return: an appropriate L{VertexClustering} object.

        @newfield ref: Reference
        @ref: Traag, V. A., Waltman, L., & van Eck, N. J. (2019). From Louvain
          to Leiden: guaranteeing well-connected communities. Scientific
          reports, 9(1), 5233. doi: 10.1038/s41598-019-41695-z
        """
        if objective_function.lower() not in ("cpm", "modularity"):
            raise ValueError('objective_function must be "CPM" or "modularity".')

        membership = GraphBase.community_leiden(
            self,
            edge_weights=weights,
            node_weights=node_weights,
            resolution_parameter=resolution_parameter,
            normalize_resolution=(objective_function == "modularity"),
            beta=beta,
            initial_membership=initial_membership,
            n_iterations=n_iterations,
        )

        if weights is not None:
            modularity_params = dict(weights=weights)
        else:
            modularity_params = {}
        return VertexClustering(self, membership, modularity_params=modularity_params)
def community_leiden ( self , objective_function = "CPM" , weights = None , resolution_parameter = 1.0 , beta = 0.01 , initial_membership = None , n_iterations = 2 , node_weights = None , ) : if objective_function . lower ( ) not in ( "cpm" , "modularity" ) : raise ValueError ( 'objective_function must be "CPM" or "modularity".' ) membership = GraphBase . community_leiden ( self , edge_weights = weights , node_weights = node_weights , resolution_parameter = resolution_parameter , normalize_resolution = ( objective_function == "modularity" ) , beta = beta , initial_membership = initial_membership , n_iterations = n_iterations , ) if weights is not None : modularity_params = dict ( weights = weights ) else : modularity_params = { } return VertexClustering ( self , membership , modularity_params = modularity_params )