now truly fixed

This commit is contained in:
René Fuhry 2023-06-05 17:27:20 +02:00 committed by GitHub
parent c734934a0d
commit b6e516269a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,13 +45,11 @@ pub fn dfs_bridges(
low_time[vertex] = time; low_time[vertex] = time;
for neighbor in 0..adjazenz_matrix.len() { for neighbor in 0..adjazenz_matrix.len() {
if adjazenz_matrix[vertex][neighbor] != 1 || visited[neighbor] { if adjazenz_matrix[vertex][neighbor] != 1 {
continue; continue;
} }
if neighbor != parent {
low_time[vertex] = usize::min(low_time[vertex], discovery_time[neighbor]);
}
if !visited[neighbor] {
dfs_bridges( dfs_bridges(
bridges, bridges,
adjazenz_matrix, adjazenz_matrix,
@ -68,6 +66,9 @@ pub fn dfs_bridges(
if discovery_time[vertex] < low_time[neighbor] { if discovery_time[vertex] < low_time[neighbor] {
bridges.push(vec![vertex + 1, neighbor + 1]); bridges.push(vec![vertex + 1, neighbor + 1]);
} }
} else if neighbor != parent {
low_time[vertex] = usize::min(low_time[vertex], discovery_time[neighbor]);
}
} }
} }
@ -90,13 +91,10 @@ pub fn dfs_articulations(
let mut articulation = false; let mut articulation = false;
for neighbor in 0..adjazenz_matrix.len() { for neighbor in 0..adjazenz_matrix.len() {
if visited[neighbor] || adjazenz_matrix[vertex][neighbor] != 1{ if adjazenz_matrix[vertex][neighbor] != 1{
continue; continue;
} }
if neighbor != parent { if !visited[neighbor] {
low_time[vertex] = usize::min(low_time[vertex], discovery_time[neighbor]);
}
child_count += 1; child_count += 1;
dfs_articulations( dfs_articulations(
articulations, articulations,
@ -112,9 +110,12 @@ pub fn dfs_articulations(
low_time[vertex] = usize::min(low_time[vertex], low_time[neighbor]); low_time[vertex] = usize::min(low_time[vertex], low_time[neighbor]);
if discovery_time[vertex] <= low_time[neighbor] { if parent != usize::MAX && discovery_time[vertex] <= low_time[neighbor] {
articulation = true; articulation = true;
} }
} else if neighbor != parent {
low_time[vertex] = usize::min(low_time[vertex], discovery_time[neighbor]);
}
} }
if parent == usize::MAX && child_count > 1 { if parent == usize::MAX && child_count > 1 {