Skip to content
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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ElePT
Copy link

@ElePT ElePT commented May 8, 2024

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.

graph: G,
filter_fn: F,
color_fn: C,
) -> Result<Vec<Vec<&<G as Data>::NodeWeight>>, CollectBicolorSimpleError<E>> //OG type: PyResult<Vec<Vec<PyObject>>>
Copy link
Member

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;
Copy link
Author

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).

@coveralls
Copy link

Pull Request Test Coverage Report for Build 9003943482

Details

  • 0 of 103 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.5%) to 95.913%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rustworkx-core/src/collect_bicolor_runs.rs 0 103 0.0%
Totals Coverage Status
Change from base Build 8992756941: -0.5%
Covered Lines: 16707
Relevant Lines: 17419

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants