Skip to main content

K-means clustering on quantum graphs and metric spaces using simulated annealing

Project description

kmeanssa-ng

License: MIT Python 3.9+ Pipeline Status Coverage Report Code style: Ruff

K-means clustering on quantum graphs and metric spaces using simulated annealing.

kmeanssa-ng provides tools for clustering data points that exist on complex network structures (quantum graphs) or other metric spaces where standard Euclidean distance does not apply. It uses a simulated annealing approach for robust convergence.

Installation

Install the latest version directly from GitLab:

pip install git+https://plmlab.math.cnrs.fr/nicolas.klutchnikoff/kmeanssa-ng.git

Quickstart

Here is a minimal example of clustering points on a quantum graph:

from kmeanssa_ng import generate_sbm, QGSimulatedAnnealing, SimulatedAnnealing

# Generate a graph with two distinct communities
graph = generate_sbm(
    sizes=[40, 40],       # Two communities of 40 nodes each
    p=[[0.8, 0.1],        # High intra-community connectivity  
       [0.1, 0.8]],       # Low inter-community connectivity
)

# Essential: precompute shortest paths
graph.precomputing()

# Sample points uniformly across the graph
points = graph.sample_points(150)

# Run quantum graph specialized simulated annealing
qg_sa = QGSimulatedAnnealing(
    observations=points,
    k=2,                  # We know there are 2 clusters
    lambda_param=1.0,     # Standard temperature
    beta=1.0,            # Standard drift strength
    step_size=0.1        # Standard step size
)

# Get cluster centers as node IDs (more interpretable)
node_centers = qg_sa.run_for_kmeans(robust_prop=0.1)
print(f"Cluster centers near nodes: {node_centers}")

Documentation

The full documentation, including API reference and tutorials, is under construction and will be available soon.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kmeanssa_ng-0.2.1.tar.gz (113.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kmeanssa_ng-0.2.1-py3-none-any.whl (109.9 kB view details)

Uploaded Python 3

File details

Details for the file kmeanssa_ng-0.2.1.tar.gz.

File metadata

  • Download URL: kmeanssa_ng-0.2.1.tar.gz
  • Upload date:
  • Size: 113.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.26.0 CPython/3.12.2 Darwin/25.0.0

File hashes

Hashes for kmeanssa_ng-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f9f98a6b797a02b33ab353f1ef1034e0ce96c6cbd44c00a6558a9652364b7e7e
MD5 2ed57b93004ccbdadffe0f4226088cc6
BLAKE2b-256 fa899807a0f3646d59f34f9ed5e74800ec8257f3be38e3cbc64ed2341e543d91

See more details on using hashes here.

File details

Details for the file kmeanssa_ng-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: kmeanssa_ng-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 109.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.26.0 CPython/3.12.2 Darwin/25.0.0

File hashes

Hashes for kmeanssa_ng-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0256326cbcfc7453faeedfd89188212d49ce86e458af833f525f38ca61d082ca
MD5 fa9b62503f32cf6f2b56b81ed19c894f
BLAKE2b-256 13850119feda23d75cbffa7a70bff11cc6693bbace90329592d78a3b7e7e5b03

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page