pub struct SimilarityBounds {
pub max_matches: Option<usize>,
pub timeout_ms: Option<u64>,
pub similarity_threshold: Option<f64>,
}Expand description
Bounds for limiting structural similarity computation.
Structural similarity uses Maximum Common Subgraph (MCS) which is NP-hard. These bounds prevent exponential blowup on large graphs.
§Example
use sqlitegraph::algo::SimilarityBounds;
// Stop after finding 100 matches or 5 seconds elapsed
let bounds = SimilarityBounds {
max_matches: Some(100),
timeout_ms: Some(5000),
similarity_threshold: Some(0.8),
..Default::default()
};Fields§
§max_matches: Option<usize>Maximum number of subgraph matches to enumerate for MCS computation.
When this limit is reached, MCS computation stops using the best match found so far. Higher values give more accurate similarity scores but take longer.
timeout_ms: Option<u64>Maximum time to spend on MCS computation (in milliseconds).
When timeout is reached, the best match found so far is used. Useful for interactive applications where responsiveness matters.
similarity_threshold: Option<f64>Optional similarity threshold for early exit.
If the isomorphism check succeeds (similarity = 1.0), or if MCS similarity reaches this threshold, computation stops early. Useful for “similar enough” checks.
Implementations§
Source§impl SimilarityBounds
impl SimilarityBounds
Sourcepub fn with_max_matches(self, max: usize) -> Self
pub fn with_max_matches(self, max: usize) -> Self
Sets the maximum number of matches for MCS enumeration.
Sourcepub fn with_timeout(self, timeout_ms: u64) -> Self
pub fn with_timeout(self, timeout_ms: u64) -> Self
Sets the timeout in milliseconds.
Sourcepub fn with_threshold(self, threshold: f64) -> Self
pub fn with_threshold(self, threshold: f64) -> Self
Sets the similarity threshold for early exit.
Sourcepub fn is_similar_enough(&self, score: f64) -> bool
pub fn is_similar_enough(&self, score: f64) -> bool
Returns true if a score is “similar enough” according to the threshold.
If no threshold is set, returns false (always continue computation).
Sourcepub fn is_bounded(&self) -> bool
pub fn is_bounded(&self) -> bool
Returns true if any bound is set.
Trait Implementations§
Source§impl Clone for SimilarityBounds
impl Clone for SimilarityBounds
Source§fn clone(&self) -> SimilarityBounds
fn clone(&self) -> SimilarityBounds
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SimilarityBounds
impl Debug for SimilarityBounds
Source§impl Default for SimilarityBounds
impl Default for SimilarityBounds
Source§fn default() -> SimilarityBounds
fn default() -> SimilarityBounds
Auto Trait Implementations§
impl Freeze for SimilarityBounds
impl RefUnwindSafe for SimilarityBounds
impl Send for SimilarityBounds
impl Sync for SimilarityBounds
impl Unpin for SimilarityBounds
impl UnwindSafe for SimilarityBounds
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more