Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
amwolff wants to merge 2 commits into yourbasic:master
base: master
Choose a base branch
Loading
from amwolff:faster-ShortestPath

Conversation

@amwolff
Copy link

@amwolff amwolff commented Oct 30, 2019
edited
Loading

I noticed that the performance of ShortestPath can 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.

  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%

Copy link
Member

korthaj commented Oct 31, 2019 via email

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> .

Copy link
Author

amwolff commented Nov 3, 2019

No problem! Let me know if you happen to have any questions regarding the patch.

Copy link
Author

amwolff commented Aug 27, 2020

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /