-
Notifications
You must be signed in to change notification settings - Fork 167
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
Algorithms for biconnected graphs. #445
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit adds two new functions: 1. `retworkx.articulation_points`. An articulation point is any node whose removal increases the number of connected components of a graph. 2. `retworkx.biconnected_components`. A biconnected component is a maximal subgraph such that the removal of a node will not disconnect the subgraph.
Pull Request Test Coverage Report for Build 1713301406
💛 - Coveralls |
georgios-ts
added a commit
to georgios-ts/retworkx
that referenced
this pull request
Sep 27, 2021
Widely used graph libraries like Boost Graph Library and graph-tool provide the ability to insert callback functions at specified event points for many common graph search algorithms. petgraph has a similar concept in `petgraph::visit::depth_first_search` function. This commit implements an iterative version of `depth_first_search`, that will be used in a follow-up in the pending PRs Qiskit#444, Qiskit#445. At the same time it exposes this new functionality in Python by letting users subclassing `retworkx.visit.DFSVisitor` and provide their own implementation for the appropriate callback functions. The benefit is less memory consumption since we avoid storing the results but rather let the user take the desired action at specified points. For example, if a user wants to process the nodes in dfs-order, we don't need to create a new list with all the graph nodes in dfs-order but rather the user can process a node on the fly. We can (probably) leverage this approach in other algorithms as an alternative for our inability to provide "real" python iterators.
Merged
mtreinish
reviewed
Jan 4, 2022
mtreinish
pushed a commit
that referenced
this pull request
Jan 10, 2022
* Add dfs-search Widely used graph libraries like Boost Graph Library and graph-tool provide the ability to insert callback functions at specified event points for many common graph search algorithms. petgraph has a similar concept in `petgraph::visit::depth_first_search` function. This commit implements an iterative version of `depth_first_search`, that will be used in a follow-up in the pending PRs #444, #445. At the same time it exposes this new functionality in Python by letting users subclassing `retworkx.visit.DFSVisitor` and provide their own implementation for the appropriate callback functions. The benefit is less memory consumption since we avoid storing the results but rather let the user take the desired action at specified points. For example, if a user wants to process the nodes in dfs-order, we don't need to create a new list with all the graph nodes in dfs-order but rather the user can process a node on the fly. We can (probably) leverage this approach in other algorithms as an alternative for our inability to provide "real" python iterators. * break or prune the search tree with custom exceptions * tests * move `depth_first_search` to retworkx-core + create a new traversal module together with `dfs_edges` function * add option to pass a vector of starting nodes + in dfs events report the weight of an edge * lint * fix docs * this is the last fix * define custom exceptions `StopSearch`, `PruneSearch` in python and import them in rust so we can simplify a bit the namespaces * minor doc fixes * ignore flake warning * run black * deduplicate macro and mention petgraph DfsEvent struct
mtreinish
approved these changes
Jan 18, 2022
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.
LGTM, thanks for the updates. Just a couple of small nits inline in the unittests but other than those I think this is ready to merge.
Co-authored-by: Matthew Treinish <[email protected]>
InnovativeInventor
pushed a commit
to InnovativeInventor/retworkx
that referenced
this pull request
Mar 19, 2022
* Algorithms for biconnected graphs. This commit adds two new functions: 1. `retworkx.articulation_points`. An articulation point is any node whose removal increases the number of connected components of a graph. 2. `retworkx.biconnected_components`. A biconnected component is a maximal subgraph such that the removal of a node will not disconnect the subgraph. * fix clippy warnings * use petgraph traits as part of the effort to have generic functions in retworkx * replace `search` with a `std::iter` build-in func * move generic function to retworkx-core * change type of biconnected components * run fmt + pre-allocate only if needed * use iterative dfs-search implementation * revert unintentional doc change * use a custom return type in biconnected components * minor changes in tests Co-authored-by: Matthew Treinish <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit adds two new functions:
retworkx.articulation_points
. An articulation point is any node whoseremoval increases the number of connected components of a graph.
retworkx.biconnected_components
. A biconnected component is amaximal subgraph such that the removal of a node will not disconnect
the subgraph.