clustering-tfjs
Version:
High-performance TypeScript clustering algorithms (K-Means, Spectral, Agglomerative) with TensorFlow.js acceleration and scikit-learn compatibility
28 lines • 1.25 kB
TypeScript
import * as tf from '../tf-adapter';
/**
* Detects the number of connected components in a graph based on its affinity matrix.
*
* A graph is considered fully connected if there's only 1 component.
* Multiple components are detected by counting near-zero eigenvalues of the Laplacian.
*
* @param affinity - Affinity/adjacency matrix (n x n)
* @param tolerance - Tolerance for detecting zero eigenvalues (default: 1e-2)
* @returns Object containing:
* - numComponents: Number of connected components
* - isFullyConnected: Whether the graph has only 1 component
* - componentLabels: Array indicating which component each node belongs to
*/
export declare function detectConnectedComponents(affinity: tf.Tensor2D, tolerance?: number): {
numComponents: number;
isFullyConnected: boolean;
componentLabels: Int32Array;
};
/**
* Issues a warning if the graph is not fully connected, similar to sklearn.
*
* @param affinity - Affinity matrix to check
* @param tolerance - Tolerance for detecting zero eigenvalues
* @returns true if graph is fully connected, false otherwise
*/
export declare function checkGraphConnectivity(affinity: tf.Tensor2D, tolerance?: number): boolean;
//# sourceMappingURL=connected_components.d.ts.map