Implementation of cycle_basis_edges
Aims to fix #551
- Inspired by the existing procedure
cycle_basis. - Modified to return a tuple of
NodeIdin the format(source, target). - Added API calls so that method works in Python.
-
TO-DO: return weights:
-
weight()method from EdgeRef returns a reference and cannot be copied over.
-
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
Results from testing in Python:
Pull Request Test Coverage Report for Build 9962098330
Details
- 87 of 102 (85.29%) changed or added relevant lines in 3 files are covered.
- No unchanged relevant lines lost coverage.
- Overall coverage decreased (-0.06%) to 95.744%
| Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
|---|---|---|---|
| rustworkx-core/src/connectivity/cycle_basis.rs | 79 | 94 | 84.04% |
| <!-- | Total: | 87 | 102 |
| Totals | |
|---|---|
| Change from base Build 9859812730: | -0.06% |
| Covered Lines: | 18108 |
| Relevant Lines: | 18913 |
💛 - Coveralls
This looks pretty good to me, just a quick question: if there a reason to declare both a cycles_edges and a cycles_nodes if from what I understand we only return one or the other? Is it possible in Rust to declare variables like:
if want_edge: let mut cycles: Vec<Vec<G::EdgeId>> = Vec::new(); else: let mut cycles: Vec<Vec<G::NodeId>> = Vec::new();. This is low-key just for me to learn
if there a reason to declare both a cycles_edges and a cycles_nodes if from what I understand we only return one or the other? Is it possible in Rust to declare variables like: if want_edge: let mut cycles: Vec<Vec<G::EdgeId>> = Vec::new(); else: let mut cycles: Vec<Vec<G::NodeId>> = Vec::new();
Well, there might be a better way of doing so that doesn't involve two vectors. The reason I did it this way is that I couldn't conditionally assign this variable with different types (G::EdgeId || G::NodeId) without having to wrap two similar processes under if and else statements, which could be a bit redundant.
I could, however, change the enum so that it represents the individual nodes/edges (instead of Vec<Vec<T>> for each type) and make the function return an instance of Vec<Vec<EdgeOrNodes<E, N>>> and then unwrap the values of said Vec individually.
The problem happens when importing this enum into the wrapper function, which complains about the types in use. I could try and get this to work with enough time.
if there a reason to declare both a cycles_edges and a cycles_nodes if from what I understand we only return one or the other? Is it possible in Rust to declare variables like: if want_edge: let mut cycles: Vec<Vec<G::EdgeId>> = Vec::new(); else: let mut cycles: Vec<Vec<G::NodeId>> = Vec::new();
Well, there might be a better way of doing so that doesn't involve two vectors. The reason I did it this way is that I couldn't conditionally assign this variable with different types (
G::EdgeId || G::NodeId) without having to wrap two similar processes under if and else statements, which could be a bit redundant.I could, however, change the enum so that it represents the individual nodes/edges (instead of
Vec<Vec<T>>for each type) and make the function return an instance ofVec<Vec<EdgeOrNodes<E, N>>>and then unwrap the values of saidVecindividually.The problem happens when importing this enum into the wrapper function, which complains about the types in use. I could try and get this to work with enough time.
I mean if it works fine, I don't see any reason to change it, I was just asking. Maybe ask @mtreinish. Otherwise, looks good