Fix bugs in dijkstra algorithm and csv parsing #8
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.
Fixes three bugs and one refactoring
Dijkstra loop should check if the popped (from priority queue) distance for node
i
is smaller than calculated distanced[i]
. This r reduces the complexity of main the loopto O( (|V|+|E| log |V|) - don't know the original's complexity - Thanks TsumoiYorozu !Fill distance array
d
in Dijkstra loop with enough big value likeINT32_MAX
to reduced[i] == 0
(checks if the node has been already visited)CSV parsing logic has a critical bug - parses integer without decimal dot to x1000 instead of x100.
Use
Int32
forDistance
type explicitly. But still not completed over all languages in this benchmark.