pub struct ClusterMap { /* private fields */ }Expand description
Pre-computed clustering of feature vectors for fast semantic grouping.
Implementations§
Source§impl ClusterMap
impl ClusterMap
Sourcepub fn build(&mut self, nodes: &[(u64, &[f32])], max_iterations: usize)
pub fn build(&mut self, nodes: &[(u64, &[f32])], max_iterations: usize)
Run k-means clustering on all feature vectors in the graph. k = min(sqrt(node_count), 256). Skips if node_count < 4.
Sourcepub fn nearest_cluster(&self, query: &[f32]) -> Option<usize>
pub fn nearest_cluster(&self, query: &[f32]) -> Option<usize>
Find the nearest cluster for a query vector.
Sourcepub fn get_cluster(&self, cluster_index: usize) -> &[u64]
pub fn get_cluster(&self, cluster_index: usize) -> &[u64]
Get all node IDs in a specific cluster.
Sourcepub fn cluster_count(&self) -> usize
pub fn cluster_count(&self) -> usize
Number of clusters.
Sourcepub fn assign_node(&mut self, node_id: u64, feature_vec: &[f32])
pub fn assign_node(&mut self, node_id: u64, feature_vec: &[f32])
Assign a new node to the nearest cluster without rebuilding.
Sourcepub fn assignments(&self) -> &[Vec<u64>]
pub fn assignments(&self) -> &[Vec<u64>]
Get assignments (for serialization).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ClusterMap
impl RefUnwindSafe for ClusterMap
impl Send for ClusterMap
impl Sync for ClusterMap
impl Unpin for ClusterMap
impl UnsafeUnpin for ClusterMap
impl UnwindSafe for ClusterMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more