Use mutable reachability rows in isolated SCC probe
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user