-
Notifications
You must be signed in to change notification settings - Fork 430
Add articulation points implementation #681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hi, great job! But I think it will be better the implementation using stack instead of recursion. Just like it was with the bridge edges search algorithm in PR #590. Practice has shown that a recursive implementation can face the problem of stack overflow. |
|
Hey, thanks for the quick reply! That is a good suggestion! I'll update the PR. |
|
Yes, I have two thoughts Picky testingI think it would be a good idea to write some randomized tests. In general, the algorithm may look like this:
Later, when version Add bench
|
47cc1cd to
3fbc423
Compare
|
Alright, sorry the late reply. I have added:
Anything further or do you have other comments on the implementation? |
|
I think all is top class now. |
|
@daehiff please update the PR description to describe the reasons for this implementation, etc. |
I forgot we have a DIscord. Just joined it. |
ABorgna
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I mostly only have nitpicks.
src/algo/articulation_points.rs
Outdated
| fn _dfs<G>( | ||
| g: &G, | ||
| target_node: usize, | ||
| visited: &mut Vec<bool>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vec<bool> uses one byte per element, since it needs to support arbitrary references.
Use a FixedBitSet instead.
src/algo/articulation_points.rs
Outdated
| _dfs( | ||
| &g, | ||
| node_id, | ||
| &mut visited, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: This could be an auxiliary state struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a struct ArticulationPointTracker, I am kindof unhappy with the naming tho.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd normally call it "Context", but it's private so it doesn't really matter.
Signed-off-by: David Winderl <winderl13@gmail.com>
Signed-off-by: David Winderl <winderl13@gmail.com>
Signed-off-by: David Winderl <winderl13@gmail.com>
Co-authored-by: Agustín Borgna <agustinborgna@gmail.com>
Co-authored-by: Agustín Borgna <agustinborgna@gmail.com>
Co-authored-by: Agustín Borgna <agustinborgna@gmail.com>
Co-authored-by: Agustín Borgna <agustinborgna@gmail.com>
Signed-off-by: daehiff <winderl13@gmail.com>
Signed-off-by: daehiff <winderl13@gmail.com>
Signed-off-by: daehiff <winderl13@gmail.com>
Signed-off-by: daehiff <winderl13@gmail.com>
Motivation
This pull request adds a function to compute articulation points in a graph using Tarjan's algorithm, implemented with an iterative approach. Articulation points are nodes whose removal increases the number of connected components in the graph.
Currently,
petgraphlacks an implementation for this functionality. This makes it impossible to for instance determine if a vertex of a graph is cutting with petgraph.Note: This approach is not a direct replication of existing implementations (e.g., [here](https://www.geeksforgeeks.org/tarjan-algorithm-find-strongly-connected-components/)), as it avoids recursion entirely.
Runtime
Tarjan's algorithm is an efficient solution to this problem, with a time complexity of (O(V + E)), making it well-suited for large graphs.