fixed dfs

This commit is contained in:
René Fuhry 2023-06-05 16:31:05 +02:00 committed by GitHub
parent 8962baadf9
commit 9236125f47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,9 +90,12 @@ pub fn dfs_articulations(
let mut articulation = false;
for neighbor in 0..adjazenz_matrix.len() {
if visited[neighbor] || neighbor == parent || parent == usize::MAX {
if visited[neighbor] || adjazenz_matrix[vertex][neighbor] != 1{
continue;
}
if neighbor != parent {
low_time[vertex] = usize::min(low_time[vertex], discovery_time[neighbor]);
}
child_count += 1;
dfs_articulations(
@ -103,8 +106,8 @@ pub fn dfs_articulations(
discovery_time,
low_time,
time,
neighbor,
vertex,
parent,
);
low_time[vertex] = usize::min(low_time[vertex], low_time[neighbor]);
@ -114,7 +117,7 @@ pub fn dfs_articulations(
}
}
if parent != usize::MAX && child_count > 1 {
if parent == usize::MAX && child_count > 1 {
articulation = true;
}