-
Notifications
You must be signed in to change notification settings - Fork 153
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 steiner tree functionality to rustworkx-core #1103
Conversation
This commit finishes the rustworkx-core port of the steiner tree and metric closure functions. In particular this was especially tricky because the petgraph traits make it exceedingly difficult to have a generic function that takes in a graph for analysis and modifies it as most of the traits required for visiting/iteration that are used for analysis are only defined on borrowed graphs, and the limited traits for modifying graphs are defined on owned graph types. This causes a conflict where you can't easily express that a generic type G created in a function from a user input is both mutated using a trait and analyzed as there is a type mismatch between G and &G. After spending far too long to fail to find a pattern to express this, I opted to just use a discrete type for the return and leave the actual graph mutation up to the rustworkx-core user because we're lacking the ability to cleanly express what is needed via petgraph.
Pull Request Test Coverage Report for Build 8132907756Details
💛 - Coveralls |
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.
The algorithm implementation looks the same and should be good, I left some comments about handling invalid inputs and errors though.
Thanks for resurrecting the PR!
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.
Thanks! This should be good to go
This PR is the continuation of #916 that finishes the port of the
steiner_tree()
andmetric_closure()
functions to rustworkx-core to enable their reuse in rust. In particular this was especially tricky because the petgraph traits make it exceedingly difficult to have a generic function that takes in a graph for analysis and modifies it as most of the traits required for visiting/iteration that are used for analysis are only defined on borrowed graphs, and the limited traits for modifying graphs are defined on owned graph types. This causes a conflict where you can't easily express that a generic typeG
created in a function from a user input is both mutated using a trait and analyzed as there is a type mismatch between G and &G. After spending far too long and failing to find a pattern to express this, I opted to just use a discrete type for the return and leave the actual graph mutation up to the rustworkx-core user because we're lacking the ability to cleanly express what is needed via petgraph. Since this was a significant rewrite of #916 and only the core algorithm (which was ported from the original rustworkx code anyway) remained the same I opted to open up a separate PR built on top of #916's branch to avoid confusion.Closes #916
Co-authored-by: Ryuhei Yoshida yoshida0112@chem.s.u-tokyo.ac.jp