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;
for neighbor in 0..adjazenz_matrix.len() {
if adjazenz_matrix[vertex][neighbor] != 1 || visited[neighbor] {
if adjazenz_matrix[vertex][neighbor] != 1 {
continue;
}
if neighbor != parent {
low_time[vertex] = usize::min(low_time[vertex], discovery_time[neighbor]);
}
if !visited[neighbor] {
dfs_bridges(
bridges,
adjazenz_matrix,
@ -68,6 +66,9 @@ pub fn dfs_bridges(
if discovery_time[vertex] < low_time[neighbor] {
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;
for neighbor in 0..adjazenz_matrix.len() {
if visited[neighbor] || adjazenz_matrix[vertex][neighbor] != 1{
if adjazenz_matrix[vertex][neighbor] != 1{
continue;
}
if neighbor != parent {
low_time[vertex] = usize::min(low_time[vertex], discovery_time[neighbor]);
}
if !visited[neighbor] {
child_count += 1;
dfs_articulations(
articulations,
@ -112,9 +110,12 @@ pub fn dfs_articulations(
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;
}
} else if neighbor != parent {
low_time[vertex] = usize::min(low_time[vertex], discovery_time[neighbor]);
}
}
if parent == usize::MAX && child_count > 1 {