maxfuse.graph.graph_clustering
- maxfuse.graph.graph_clustering(n, edges, resolution=1, n_clusters=None, n_runs=1, resolution_tol=0.05, seed=None, verbose=False)[source]
Cluster the graph defined by edges and weights using Leiden algorithm.
- 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 (None or int, default=1) – If not None, then this is the resolution parameter in the clustering algorithm, if None, then n_clusters must be not None.
n_clusters (None or int, default=None) – If not None, use binary search to select the resolution parameter to achieve the desired number of clusters, if None, then resolution must be not None.
n_runs (int, default=1) – Number of runs of Leiden algorithm, the run with the best modularity is taken as the output.
resolution_tol (float, default=0.05) – Any resolution within the range of plus/minus resolution_tol will not be differentiated.
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