-
Couldn't load subscription status.
- Fork 65
Make ShortestPath faster #7
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
Open
Open
Conversation
This file contains hidden or 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
Artur, thanks a lot for the patch! I will certainly add this. However, I'm,
really busy right now so it might take a few weeks.
... On Wed, Oct 30, 2019 at 10:18 PM Artur M. Wolff ***@***.***> wrote:
I noticed that the performance of ShortestPath can be substantially
improved. Instead of finding all shortest paths from the initial vertex,
then picking the shortest path between *v* and *w* we want, we could
terminate the search as soon as we found the path to the desired vertex.
I've opened a pull request, because I already have a patch.
1. No API changes whatsoever;
2. This performance enhancement is based on the original E. W.
Dijkstra's paper (it's what should be found in a CS textbook).
old/new comparison:
benchmark old ns/op new ns/op delta
BenchmarkShortestPath250-4 55089 31078 -43.59%
BenchmarkShortestPath500-4 121956 51563 -57.72%
BenchmarkShortestPath1000-4 206507 79512 -61.50%
------------------------------
You can view, comment on, or merge this pull request online at:
#7
Commit Summary
- Make ShortestPath faster
File Changes
- *M* path.go <https://github.com/yourbasic/graph/pull/7/files#diff-0>
(51)
- *M* path_test.go
<https://github.com/yourbasic/graph/pull/7/files#diff-1> (66)
Patch Links:
- https://github.com/yourbasic/graph/pull/7.patch
- https://github.com/yourbasic/graph/pull/7.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#7?email_source=notifications&email_token=ACVN3SZLBXKYSWNXMPOUVN3QRH2ZBA5CNFSM4JHAPC3KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HVSDIHQ>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACVN3S5ULMPF6WB3UYYPOP3QRH2ZBANCNFSM4JHAPC3A>
.
No problem! Let me know if you happen to have any questions regarding the patch.
I was going through my old contributions and realized I made a mistake here in the comment about ShortestPath (it should be kept original). I've fixed this in case this may get merged. :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
I noticed that the performance of
ShortestPathcan be substantially improved. Instead of finding all the shortest paths from the initial vertex, we could terminate the search as soon as we found the path to the destination vertex.I've opened a pull request because I already have a patch.
old/new comparison: