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

Add function to approximate minimum Steiner tree #392

Merged
merged 16 commits into from
Aug 13, 2021

Conversation

mtreinish
Copy link
Member

@mtreinish mtreinish commented Jul 20, 2021

This commit adds a function to find an approximation of the minimum
Steiner tree using the algorithm described in "A fast algorithm for
Steiner tree" Kou, Markowsky & Berman (1981).
https://link.springer.com/article/10.1007/BF00288961
This algorithm produces a tree whose weight is within a (2 - (2 / t))
factor of the weight of the optimal Steiner tree where t is the number
of terminal nodes.

Closes #389

TODO:

  • Add docs
  • Expand test coverage
  • Add output graph edge de-duplication for parallel edges in a multigraph
  • Add release notes

@coveralls
Copy link

coveralls commented Jul 20, 2021

Pull Request Test Coverage Report for Build 1127740546

  • 117 of 123 (95.12%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.08%) to 97.662%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/steiner_tree.rs 115 121 95.04%
Totals Coverage Status
Change from base Build 1127680880: -0.08%
Covered Lines: 8898
Relevant Lines: 9111

💛 - Coveralls

@mtreinish mtreinish added this to the 0.10.0 milestone Aug 3, 2021
@mtreinish mtreinish changed the title [WIP] Add function to approximate minimum Steiner tree Add function to approximate minimum Steiner tree Aug 4, 2021
This commit adds a function to find an approximation of the minimum
Steiner tree using the algorithm described in "A fast algorithm for
Steiner tree" Kou, Markowsky & Berman (1981).
https://link.springer.com/article/10.1007/BF00288961
This algorithm produces a tree whose weight is within a (2 - (2 / t))
factor of the weight of the optimal Steiner tree where t is the number
of terminal nodes.

Closes Qiskit#389
@mtreinish
Copy link
Member Author

hmm, the test I borrowed form networkx seems to have something non-deterministic in it: https://github.com/Qiskit/retworkx/pull/392/checks?check_run_id=3251676024#step:7:1251 it's failing in some cases. I'll have to dig into that.

In Qiskit#390 one of the last changes made to the PR before merging was:
Qiskit@3353b4b
which changed the final loop constructing the metric closure edges from
iterating over node indices and pulling the path from the hashmap for
that index to just iterating over the hashmap. That however had the
unintended side effect of introducing non-determinism to the output as
the iteration order over a hashmap isn't guaranteed. This was causing
failures in the steiner tree function as the metric closure edge order
can affect the computed tree. This commit fixes this by switching back
to using the node id order for the final output generation and adds a
comment as to why.
@mtreinish
Copy link
Member Author

eb2a0aa should fix the test non-determinism and I think this is ready now

Copy link
Collaborator

@georgios-ts georgios-ts 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 updates.

This adds a test case with an input graph that has equal distances. It
is a test based on a review comment [1] that was previously producing an
incorrect output (that wasn't even a tree). After fixing the underlying
issue it would be good to have this tested to ensure we don't regress on
it in the future.

Co-authored-by: georgios-ts <[email protected]>

[1] Qiskit#392 (comment)
@mtreinish mtreinish merged commit 05ae8b3 into Qiskit:main Aug 13, 2021
@mtreinish mtreinish deleted the steiner_tree branch August 13, 2021 13:40
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.

Add minimum steiner tree function
3 participants