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
[WIP] Move collect_bicolor_runs()
to rustworkx-core
#1186
base: main
Are you sure you want to change the base?
Conversation
graph: G, | ||
filter_fn: F, | ||
color_fn: C, | ||
) -> Result<Vec<Vec<&<G as Data>::NodeWeight>>, CollectBicolorSimpleError<E>> //OG type: PyResult<Vec<Vec<PyObject>>> |
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.
Instead of returning NodeWeight
here I think it would be simpler to just return something like:
impl Iterator<Item=Vec<G::NodeId>>
(or something like that I might have made a mistake in the exact syntax) Or alternatively a Vec<Vec<G::NodeId>>
The idea is to return an iterator of node indices for each run. This isn't exactly what the python api was returning, but retunring the node ids will let us easily iterate and map that to the weights for python, but for other rust consumer (especially Qiskit in the future) this will be lighter weight to work with because it's a simple vec get to go from an index to a weight.
Then using an iterator would be a more rust native interface to return an iterator of the runs
@@ -73,6 +73,7 @@ pub type Result<T, E = Infallible> = core::result::Result<T, E>; | |||
pub mod bipartite_coloring; | |||
/// Module for centrality algorithms. | |||
pub mod centrality; | |||
pub mod collect_bicolor_runs; |
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.
This was moved from under pub mod connectivitiy
when I ran cargo fmt
, I guess that they must be in alphabetical order (I will move it back to coloring algorithms).
Pull Request Test Coverage Report for Build 9003943482Details
💛 - Coveralls |
This is a first attempt at solving #1166. The code is WIP, it compiles (yay!), but it's missing some polishing. I need to look again at the custom error classes (I did it looking at ##1143, but I think this case is simpler). The current function returns a
<Vec<Vec<G::NodeId>>
but I'd also like to see if I can implement the iterator mentioned in the original issue. Finally, the Python-facing function should be modified to use this one.