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

Loosen trait constraints and simplify structure for longest_path #1195

Merged
merged 1 commit into from
May 18, 2024

Conversation

mtreinish
Copy link
Member

In the recently merged #1192 a new generic DAG longest_path function was added to rustworkx-core. However, the trait bounds on the function were a bit tighter than they needed to be. The traits were forcing NodeId to be of a NodeIndex type and this wasn't really required. The only requirement that the NodeId type can be put on a hashmap and do a partial compare (that implements Hash, Eq, and PartialOrd). Also the IntoNeighborsDirected wasn't required because it's methods weren't ever used. This commit loosens the traits bounds to facilitate this. At the same time this also simplifies the code structure a bit to reduce the separation of the rust code structure in the rustworkx crate using longest_path().

In the recently merged Qiskit#1192 a new generic DAG longest_path function was
added to rustworkx-core. However, the trait bounds on the function were
a bit tighter than they needed to be. The traits were forcing NodeId to
be of a NodeIndex type and this wasn't really required. The only
requirement that the NodeId type can be put on a hashmap and do a
partial compare (that implements Hash, Eq, and PartialOrd). Also the
IntoNeighborsDirected wasn't required because it's methods weren't ever
used. This commit loosens the traits bounds to facilitate this. At the
same time this also simplifies the code structure a bit to reduce the
separation of the rust code structure in the rustworkx crate using
longest_path().
@coveralls
Copy link

Pull Request Test Coverage Report for Build 9133077909

Details

  • 33 of 33 (100.0%) changed or added relevant lines in 2 files are covered.
  • 6 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.04%) to 96.474%

Files with Coverage Reduction New Missed Lines %
src/shortest_path/all_pairs_bellman_ford.rs 6 95.53%
Totals Coverage Status
Change from base Build 9104623275: -0.04%
Covered Lines: 16744
Relevant Lines: 17356

💛 - Coveralls

Copy link
Collaborator

@IvanIsCoding IvanIsCoding left a comment

Choose a reason for hiding this comment

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

LGTM

@IvanIsCoding IvanIsCoding merged commit 0ec113b into Qiskit:main May 18, 2024
28 checks passed
@mtreinish mtreinish deleted the traits-longest-path branch May 18, 2024 12:05
SILIZ4 pushed a commit to SILIZ4/rustworkx that referenced this pull request May 18, 2024
…kit#1195)

In the recently merged Qiskit#1192 a new generic DAG longest_path function was
added to rustworkx-core. However, the trait bounds on the function were
a bit tighter than they needed to be. The traits were forcing NodeId to
be of a NodeIndex type and this wasn't really required. The only
requirement that the NodeId type can be put on a hashmap and do a
partial compare (that implements Hash, Eq, and PartialOrd). Also the
IntoNeighborsDirected wasn't required because it's methods weren't ever
used. This commit loosens the traits bounds to facilitate this. At the
same time this also simplifies the code structure a bit to reduce the
separation of the rust code structure in the rustworkx crate using
longest_path().
IvanIsCoding added a commit that referenced this pull request May 22, 2024
* add hyperbolic random graph model generator

* Loosen trait constraints and simplify structure for longest_path (#1195)

In the recently merged #1192 a new generic DAG longest_path function was
added to rustworkx-core. However, the trait bounds on the function were
a bit tighter than they needed to be. The traits were forcing NodeId to
be of a NodeIndex type and this wasn't really required. The only
requirement that the NodeId type can be put on a hashmap and do a
partial compare (that implements Hash, Eq, and PartialOrd). Also the
IntoNeighborsDirected wasn't required because it's methods weren't ever
used. This commit loosens the traits bounds to facilitate this. At the
same time this also simplifies the code structure a bit to reduce the
separation of the rust code structure in the rustworkx crate using
longest_path().

* use vector references

* change to slice (clippy)

* generalize to H^D, improve numerical accuracy

* allow infinite coordinate

* handle infinity in hyperbolic distance

* remove unused import (clippy)

* fix python stub

---------

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
IvanIsCoding added a commit that referenced this pull request Jun 8, 2024
* add hyperbolic random graph model generator

* Loosen trait constraints and simplify structure for longest_path (#1195)

In the recently merged #1192 a new generic DAG longest_path function was
added to rustworkx-core. However, the trait bounds on the function were
a bit tighter than they needed to be. The traits were forcing NodeId to
be of a NodeIndex type and this wasn't really required. The only
requirement that the NodeId type can be put on a hashmap and do a
partial compare (that implements Hash, Eq, and PartialOrd). Also the
IntoNeighborsDirected wasn't required because it's methods weren't ever
used. This commit loosens the traits bounds to facilitate this. At the
same time this also simplifies the code structure a bit to reduce the
separation of the rust code structure in the rustworkx crate using
longest_path().

* use vector references

* change to slice (clippy)

* generalize to H^D, improve numerical accuracy

* allow infinite coordinate

* handle infinity in hyperbolic distance

* remove unused import (clippy)

* fix python stub

* Rename deprecated cargo config file (#1211)

This commit migrates the .cargo/config file which has been deprecated to
the new path .cargo/config.toml. This will fix warnings that are emitted
when compiling with the latest stable release. This new path has been
supported since Rust 1.38 which is much older than our current MSRV of
1.70.

* fix hyperbolic distance, swap r and beta, infer time coordinate

* use mul_add in hyperbolic distance, remove release note

* replace clone with dereference

---------

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
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.

3 participants