Skip to content

Conversation

alexanderivrii
Copy link
Member

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
Member 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
@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