maxfuse.graph.leiden_clustering
- maxfuse.graph.leiden_clustering(n, edges, resolution=1, n_runs=1, seed=None, verbose=False)[source]
Apply Leiden modularity maximization algorithm on the graph defined by edges and weights
- Parameters:
n (int) – Number of edges in total
edges (list of length two or three) – If length is two, then the graph is unweighted and each edge is (edges[0][i], edges[1][i]), if the length is three, then the graph is weighted and the weight of (edges[0][i], edges[1][i]) is edges[2][i].
resolution (float, default=1) – Resolution parameter in Leiden algorithm
n_runs (int, default=1) – Number of runs of Leiden algorithm, the run with the best modularity is taken as the output
seed (None or int, default=None) – Random seed used. If None, use a random integer. If n_runs > 1, then seed will be reset to None.
verbose (bool, default=True) – Whether to print progress
- Returns:
labels (np.array of shape (n,)) – Cluster labels