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

Uploaded Python 3

File details

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

File metadata

  • Download URL: kmeanssa_ng-0.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 e6867ca39da08850b7737410267219a2767676942138e819956e10f9a2f3cbab
MD5 a816dc52ed41517b52bedbaa8942b837
BLAKE2b-256 4ea9b6e80fab91a5b6bcf11f9bd1af80707a03f3db7e11119009cc0143005699

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kmeanssa_ng-0.2.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3c45f23b6860a2c6deeaa87eb8be886962fb7130892c722e338ead254deffe4
MD5 4fc451105f3d816049242d8e4ce87830
BLAKE2b-256 def78d56af0e8e7e44ecba5cf1737f4e8b8e602ddd4fa6c30e851ffc958bd630

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