Scikit-network

0.33.5 · active · verified Mon Apr 13

Scikit-network is a Python library for the analysis of large graphs, providing state-of-the-art algorithms for clustering, classification, ranking, embedding, and more. It is currently at version 0.33.5 and actively maintained with frequent minor releases that include new features, bug fixes, and Python version support.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to load a sample graph and apply the Louvain clustering algorithm to detect communities. It prints the number of nodes, a snippet of the assigned labels, and the total number of unique clusters found.

from sknetwork.data import karate_club
from sknetwork.clustering import Louvain

# Load an example graph (Karate Club dataset)
graph = karate_club()
adjacency = graph.adjacency

# Apply Louvain clustering algorithm
louvain = Louvain()
labels = louvain.fit_predict(adjacency)

print(f"Number of nodes: {adjacency.shape[0]}")
print(f"Detected cluster labels (first 10): {labels[:10]}")
print(f"Unique clusters found: {len(set(labels))}")

view raw JSON →