// LLP driver for the least mincut satisfying a lattice-linear side // predicate. The hooks b_check, forbidden_for_b, and next_mincut are // problem-specific; the driver here is illustrative only. fn b_check(_c: &[bool]) -> bool { true } fn forbidden_for_b(_j: usize, _c: &[bool]) -> bool { false } fn next_mincut(c: &[bool]) -> Vec { c.to_vec() } fn llp_mincut(mut c: Vec) -> Vec { let n = c.len(); let mut done = false; while !done { let mut changed = true; while changed { changed = false; for j in 0..n { if forbidden_for_b(j, &c) { if c[j] { return vec![]; } c[j] = true; changed = true; } } } if b_check(&c) { done = true; } else { let next = next_mincut(&c); if next.is_empty() { return vec![]; } c = next; } } c } fn main() { let c = vec![false; 4]; let out = llp_mincut(c); print!("C:"); for b in &out { print!(" {}", if *b { 1 } else { 0 }); } println!(); }