-
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
Add chain_decomposition
function.
#444
Conversation
This commit adds a new function that finds a chain decomposition of an undirected . It's defined in https://doi.org/10.1016/j.ipl.2013.01.016 and can be used to compute all bridges and cut vertices of the input graph. One current limitation is that it's a recursive implementation since it's based on the .
Pull Request Test Coverage Report for Build 1346792751
💛 - Coveralls |
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.
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.
Overall this LGTM. I'm not familiar with this algorithm I've got to read the paper before I can have any comments on the correctness there. But going through the code it looks good. I just had one inline comment on how we can potentially improve the final output collection
Co-authored-by: Matthew Treinish <[email protected]>
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.
Ok, I've read the paper (it's quite the simple algorithm) the code looks good on that point. I left a few inline comments mostly about docs and one inline question. Otherwise I think this is good to go.
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, sorry for the delay in the review and thanks for pushing this up and the quick updates
* 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
This commit adds a new function that finds a
chain decomposition of an undirected
PyGraph
.It's defined in https://doi.org/10.1016/j.ipl.2013.01.016
and can be used to compute all bridges and cut
vertices of the input graph.
One current limitation is that it's a recursive implementation
since it's based on the
petgraph::depth_first_search
.