Conversation
test/alg/extract-path-tests.js
Outdated
|
|
||
| it("returns weight: 0 and path: [source], from source to source", function() { | ||
| var shortestPaths = { | ||
| "a": { distance:0 }, |
test/alg/extract-path-tests.js
Outdated
|
|
||
| it("throws an error when given an invalid destination vertex", function() { | ||
| var shortestPaths = { | ||
| "a": { distance:0 }, |
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.
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.
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.
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 .