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.3.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.3-py3-none-any.whl (109.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kmeanssa_ng-0.2.3.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.3.tar.gz
Algorithm Hash digest
SHA256 254b515c160ebc21f482ea2ca4e8566a67423a3a5d1edb825695b03dd189cce6
MD5 601358c78db6fa5c6e78c172f49ee8f1
BLAKE2b-256 2ce1e47691c5300a9d08e5a56c7a3cbe454433172f1a4c585780a872c9d6973c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kmeanssa_ng-0.2.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1a35818d395fba1d0f3eb064cf15b1180e8a329ee20572256b9df9c83ad67edd
MD5 ee0939824d2d262701d785918cefe67d
BLAKE2b-256 d26e032a2de877039f0548f1666bfe9a75f9c18e3b0a88beacdfe0c71aac42b2

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