-
Notifications
You must be signed in to change notification settings - Fork 235
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
Extract path #94
base: master
Are you sure you want to change the base?
Extract path #94
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
test/alg/extract-path-tests.js
Outdated
|
||
it("returns weight: 0 and path: [source], from source to source", function() { | ||
var shortestPaths = { | ||
"a": { distance:0 }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: space after :
test/alg/extract-path-tests.js
Outdated
|
||
it("throws an error when given an invalid destination vertex", function() { | ||
var shortestPaths = { | ||
"a": { distance:0 }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: space after :
test/alg/extract-path-tests.js
Outdated
"a": { distance: 0 }, | ||
"b": { distance: 17, predecessor: "d" }, | ||
"c": { distance: 42, predecessor: "b" }, | ||
"d": { distance: 73, predecessor: "c" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible for this output to ever be the output of a shortest paths algorithm? Can you give an example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ( or similar cyclic results ) can not be the output of a shortest path algorithm, so the cycle detection might be an overkill here. I just added it to the implementation so that we can be sure that runExtractPath() will always exit its recursion, indepedendly of the results object that it is called on. Appart from that, I can't really see a use case in which extractPath() will be called on an object not produced by a shortest path algorithm , so I can remove it if u wish
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think removing this test would be sensible.
I refactored runExtractPath(), now it just iterates on predecessors and pushes them in the path array. When the iteration is finished, it reverses the array and returns it. Just for history - I also had a second option, to push each predecessor at the start of the array with |
This is not unexpected - |
Yes, of course this result was expexted! - I couldnt find the |
PTAL :) |
LGTM. Good job once again! |
Please rebase and squash commits with the commits that they fix so that your history is clean. |
ee00ef6
to
2862de4
Compare
64a1b87
to
cf48a25
Compare
Hello, will this pr be merged any time soon? I see activity in Feb, but last comment is from Sep 2019. |
@tdmartino, can you review this change and do some more testing? |
also looking at this PR |
Nice work!
|
Thanks for the review @assafsun ! I agree with your points, I'll make the necessary changes |
@mstou Thanks for the update |
Welp, I also could really use this. Until then i'll just use the pr code |
This pull request fixes #89 .