Use mutable reachability rows in isolated SCC probe

This commit is contained in:
2026-09-24 21:17:11 -07:00
parent ea18adc061
commit 4dd764fa6c
@@ -22,14 +22,14 @@ fn charge(work: &mut usize, count: usize) -> Result<(), ModelError> {
fn components(arcs: &[BTreeSet<usize>], work: &mut usize) -> Result<Vec<Vec<usize>>, ModelError> {
let n = arcs.len();
let mut reach = vec![vec![false; n]; n];
for start in 0..n {
for (start, reachable) in reach.iter_mut().enumerate() {
let mut todo = vec![start];
reach[start][start] = true;
reachable[start] = true;
while let Some(at) = todo.pop() {
for &next in &arcs[at] {
charge(work, 1)?;
if !reach[start][next] {
reach[start][next] = true;
if !reachable[next] {
reachable[next] = true;
todo.push(next);
}
}
@@ -583,6 +583,5 @@ mod tests {
positions,
vec![Position { x: 0.0, y: 0.0 }, Position { x: 0.0, y: 216.0 }]
);
assert!(224.0_f32 / 376.0 > 0.5);
}
}