Source code for src.algorithms.traditional.Leiden

from cdlib.algorithms import leiden

from algorithms.Algorithm import Algorithm
from .utils import extract_clusters_from_communities_list


[docs] class Leiden(Algorithm): """Leiden clustering algorithm """
[docs] def run(self) -> None: """Runs the algorithm """ clustering = leiden(self.graph.nx_graph) self.clusters = extract_clusters_from_communities_list(clustering.communities)
def __str__(self): """Returns the string representation of the algorithm object :return: String representation of the algorithm object :rtype: str """ return "Leiden algorithm object"