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

mapping is not possible when a node has no neighbors #995

Merged
merged 3 commits into from
Oct 6, 2023

Conversation

alexanderivrii
Copy link
Contributor

Fixes #994.

I believe that the function add_token_edges(node) should return Err(MapNotPossible {}) when no mapping exists. This was already handled in the case that node had at least one neighbor. Now I am also returning the error in the case a node has no neighbors.

@coveralls
Copy link

coveralls commented Oct 5, 2023

Pull Request Test Coverage Report for Build 6431767936

  • 3 of 4 (75.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.005%) to 96.492%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rustworkx-core/src/token_swapper.rs 3 4 75.0%
Totals Coverage Status
Change from base Build 6427098456: -0.005%
Covered Lines: 15431
Relevant Lines: 15992

💛 - Coveralls

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, just one inline comment that I think will be more efficient.

Comment on lines 211 to 213
.neighbors(id_node)
.collect::<Vec<G::NodeId>>()
.is_empty()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.neighbors(id_node)
.collect::<Vec<G::NodeId>>()
.is_empty()
.neighbors(id_node)
.next()
.is_some()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is how one can directly check whether an iterator is empty or non-empty, I was wondering about that. Fixed in d682b9b.

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the quick update and also fixing the mistake in my suggestion :D

@mtreinish mtreinish added the automerge Queue a approved PR for merging label Oct 6, 2023
@mergify mergify bot merged commit 2d5694e into Qiskit:main Oct 6, 2023
26 checks passed
@alexanderivrii alexanderivrii deleted the token-swapper-fix branch February 9, 2024 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Queue a approved PR for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Token_swapper fails on graphs with edgeless nodes
3 participants