pub struct SemanticGraphLinker {
pub nodes: HashMap<u64, GraphNode>,
pub edges: Vec<SemanticEdge>,
pub config: LinkerConfig,
}Expand description
Builds and queries a semantic similarity graph over embedding vectors.
Fields§
§nodes: HashMap<u64, GraphNode>§edges: Vec<SemanticEdge>§config: LinkerConfigImplementations§
Source§impl SemanticGraphLinker
impl SemanticGraphLinker
Sourcepub fn new(config: LinkerConfig) -> Self
pub fn new(config: LinkerConfig) -> Self
Creates a new linker with the provided configuration.
Sourcepub fn add_node(&mut self, node: GraphNode)
pub fn add_node(&mut self, node: GraphNode)
Inserts a node into the graph. Any existing node with the same id is
replaced (its edges are not automatically removed; call remove_node
first if you want a clean replacement).
Sourcepub fn link_all(&mut self)
pub fn link_all(&mut self)
Links all node pairs whose cosine similarity exceeds the configured
thresholds, then enforces the max_edges_per_node cap.
Calling this method more than once is safe but will duplicate edges for pairs that were already linked; it is the caller’s responsibility to clear edges first if a full rebuild is desired.
Sourcepub fn neighbors(&self, node_id: u64) -> Vec<u64>
pub fn neighbors(&self, node_id: u64) -> Vec<u64>
Returns the IDs of all nodes directly adjacent to node_id.
Sourcepub fn connected_components(&self) -> Vec<Vec<u64>>
pub fn connected_components(&self) -> Vec<Vec<u64>>
Computes connected components considering only SimilarContent and
Duplicate edges (using union-find).
Sourcepub fn remove_node(&mut self, node_id: u64)
pub fn remove_node(&mut self, node_id: u64)
Removes a node and all edges incident to it from the graph.
Sourcepub fn stats(&self) -> GraphLinkerStats
pub fn stats(&self) -> GraphLinkerStats
Returns aggregate statistics for the current graph.
Auto Trait Implementations§
impl Freeze for SemanticGraphLinker
impl RefUnwindSafe for SemanticGraphLinker
impl Send for SemanticGraphLinker
impl Sync for SemanticGraphLinker
impl Unpin for SemanticGraphLinker
impl UnsafeUnpin for SemanticGraphLinker
impl UnwindSafe for SemanticGraphLinker
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.