-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add function to approximate minimum Steiner tree (#392)
* Add steiner_tree function 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 * Add more tests * Switch to iterating over node indices in metric_closure In #390 one of the last changes made to the PR before merging was: 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. * Fix release notes * Apply suggestions from code review Co-authored-by: georgios-ts <[email protected]> * Split out edge deduplication to separate function * Attempt to avoid cycles by using src and target in sort Co-authored-by: georgios-ts <[email protected]> * Remove input graph usage in edge deduplication Co-authored-by: georgios-ts <[email protected]> * Move steiner_tree() to Tree docs section * Add test case with equal distances 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. [1] #392 (comment) Co-authored-by: georgios-ts <[email protected]>
- Loading branch information
1 parent
adaeb31
commit 05ae8b3
Showing
6 changed files
with
264 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters