File tree Expand file tree Collapse file tree
crates/ruvector-mincut/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5454//! let mut jtree = JTreeHierarchy::build(graph, config).unwrap();
5555//!
5656//! // Query approximate min-cut (Tier 1)
57- //! let approx = jtree.approximate_min_cut();
57+ //! let approx = jtree.approximate_min_cut().unwrap() ;
5858//! println!("Approximate min-cut: {} (factor: {})", approx.value, approx.approximation_factor);
5959//!
6060//! // Handle dynamic updates
Original file line number Diff line number Diff line change @@ -165,9 +165,19 @@ impl BenchmarkSuite {
165165 }
166166
167167 // Estimate combined speedup (conservative: product of square roots)
168+ // Skip results with zero or negative speedup to avoid NaN
168169 let mut combined = 1.0 ;
170+ let mut count = 0 ;
169171 for result in & self . results {
170- combined *= result. summary . avg_speedup . sqrt ( ) ;
172+ let speedup = result. summary . avg_speedup ;
173+ if speedup > 0.0 && speedup. is_finite ( ) {
174+ combined *= speedup. sqrt ( ) ;
175+ count += 1 ;
176+ }
177+ }
178+
179+ if count == 0 {
180+ return 1.0 ;
171181 }
172182
173183 combined
@@ -703,7 +713,10 @@ mod tests {
703713 suite. run_all ( ) ;
704714 let combined = suite. combined_speedup ( ) ;
705715
706- assert ! ( combined > 0.0 ) ;
716+ // For very small inputs, overhead may exceed benefit
717+ // Just verify we get a valid positive result
718+ assert ! ( combined > 0.0 && combined. is_finite( ) ,
719+ "Combined speedup {} should be positive and finite" , combined) ;
707720 }
708721
709722 #[ test]
Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ impl ParallelLevelUpdater {
201201 Self {
202202 scheduler : Arc :: new ( WorkStealingScheduler :: with_config ( config. clone ( ) ) ) ,
203203 config,
204- global_min : AtomicU64 :: new ( u64 :: MAX ) ,
204+ global_min : AtomicU64 :: new ( f64 :: INFINITY . to_bits ( ) ) ,
205205 best_level : AtomicUsize :: new ( usize:: MAX ) ,
206206 }
207207 }
@@ -249,7 +249,7 @@ impl ParallelLevelUpdater {
249249
250250 /// Reset global minimum
251251 pub fn reset_min ( & self ) {
252- self . global_min . store ( u64 :: MAX , Ordering :: Release ) ;
252+ self . global_min . store ( f64 :: INFINITY . to_bits ( ) , Ordering :: Release ) ;
253253 self . best_level . store ( usize:: MAX , Ordering :: Release ) ;
254254 }
255255
You can’t perform that action at this time.
0 commit comments