For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
GitHubCUDA-X
    • Home
    • Installation
  • Getting Started
    • Introduction
    • Integrations
    • Use-cases
  • User Guide
    • API Guide
    • Benchmarking Guide
    • Field Guide
    • References
  • Developer Guide
    • Coding Guidelines
    • Contributing
  • API Reference
    • C API Documentation
    • Cpp API Documentation
      • Cluster Agglomerative
      • Cluster Kmeans
      • Cluster Spectral
      • Common Types
      • Distance Distance
      • Distance Grammian
      • Neighbors All Neighbors
      • Neighbors Ball Cover
      • Neighbors Brute Force
      • Neighbors Cagra
      • Neighbors Common
      • Neighbors Dynamic Batching
      • Neighbors Epsilon Neighborhood
      • Neighbors HNSW
      • Neighbors Composite Index
      • Neighbors IVF Flat
      • Neighbors IVF PQ
      • Neighbors IVF SQ
      • Neighbors NN Descent
      • Neighbors Refine
      • Neighbors Scann
      • Neighbors Tiered Index
      • Neighbors Vamana
      • Preprocessing Quantize Binary
      • Preprocessing PCA
      • Preprocessing Quantize PQ
      • Preprocessing Quantize Scalar
      • Preprocessing Spectral Embedding
      • Selection Select K
      • Stats Silhouette Score
      • Stats Trustworthiness Score
      • Util Cutlass Utils
      • Util File Io
    • Python API Documentation
    • Java API Documentation
    • Rust API Documentation
    • Go API Documentation
NVIDIANVIDIA
Developer-friendly docs for your API
Privacy Policy | Your Privacy Choices | Terms of Service | Accessibility | Corporate Policies | Product Security | Contact

Copyright © 2026, NVIDIA Corporation.

LogoLogocuVS
GitHubCUDA-X
On this page
  • Spectral Clustering Parameters
  • cluster::spectral::params
  • Spectral Clustering
  • cluster::spectral::fit_predict
API ReferenceCpp API Documentation

Spectral

||View as Markdown|
Previous

Cluster Kmeans

Next

Common Types

Source header: cuvs/cluster/spectral.hpp

Spectral Clustering Parameters

cluster::spectral::params

Parameters for spectral clustering

1struct params {
2 int n_clusters;
3 int n_components;
4 int n_init;
5 int n_neighbors;
6 float tolerance;
7 raft::random::RngState rng_state;
8};

Fields

NameTypeDescription
n_clustersintNumber of clusters to find
n_componentsintNumber of eigenvectors to use for the spectral embedding (typically equal to n_clusters)
n_initintNumber of k-means runs with different centroid seeds
n_neighborsintNumber of nearest neighbors for constructing the connectivity graph
tolerancefloatTolerance for the eigenvalue solver
rng_stateraft::random::RngStateRandom number generator state for reproducibility

Spectral Clustering

cluster::spectral::fit_predict

Perform spectral clustering on a connectivity graph

1void fit_predict(raft::resources const& handle,
2params config,
3raft::device_coo_matrix_view<float, int, int, int> connectivity_graph,
4raft::device_vector_view<int, int> labels);

Parameters

NameDirectionTypeDescription
handleinraft::resources const&RAFT resource handle
configinparamsSpectral clustering parameters
connectivity_graphinraft::device_coo_matrix_view<float, int, int, int>Sparse COO matrix representing connectivity between data points
labelsoutraft::device_vector_view<int, int>Device vector of size n_samples to store cluster assignments (0 to n_clusters-1)

Returns

void

Additional overload: cluster::spectral::fit_predict

Perform spectral clustering on a connectivity graph

1void fit_predict(raft::resources const& handle,
2params config,
3raft::device_coo_matrix_view<double, int, int, int> connectivity_graph,
4raft::device_vector_view<int, int> labels);

Parameters

NameDirectionTypeDescription
handleinraft::resources const&RAFT resource handle
configinparamsSpectral clustering parameters
connectivity_graphinraft::device_coo_matrix_view<double, int, int, int>Sparse COO matrix representing connectivity between data points
labelsoutraft::device_vector_view<int, int>Device vector of size n_samples to store cluster assignments (0 to n_clusters-1)

Returns

void

Additional overload: cluster::spectral::fit_predict

Perform spectral clustering on a dense dataset

1void fit_predict(raft::resources const& handle,
2params config,
3raft::device_matrix_view<float, int, raft::row_major> dataset,
4raft::device_vector_view<int, int> labels);

This overload automatically constructs the connectivity graph from the input dataset using k-nearest neighbors.

Parameters

NameDirectionTypeDescription
handleinraft::resources const&RAFT resource handle
configinparamsSpectral clustering parameters
datasetinraft::device_matrix_view<float, int, raft::row_major>Dense row-major matrix of shape (n_samples, n_features)
labelsoutraft::device_vector_view<int, int>Device vector of size n_samples to store cluster assignments (0 to n_clusters-1)

Returns

void