Skip to content
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

Don't store dist as key in frontier #54

Merged
merged 2 commits into from
Aug 30, 2021
Merged

Conversation

blegat
Copy link
Contributor

@blegat blegat commented Aug 28, 2021

In A*/Dijkstra, there is two approaches for the datastructure:

  1. Use a heap, it's very cheap but you can't update the value of a node so you will store the node several times with different distances and once the first one comes out of the heap, you know you can just ignore the rest. Each operation is super cheap as it's just implemented as a Vector
  2. Use a full-fledged priority queue where you can update values so you never store more elements as the number of nodes you have, but each operation is more costly.

Here, a full-fledged priority queue is used but the distance is stored as well so the same nodes will occupy several slots in the priority queue! In fact, we never check when a node is taken out of the priority queue that the color of this not is not already 2 so we may treat the same node several time!

This PR fixes the issue by not storing the distance in the key, it's in dists anyway.

@pszufe
Copy link
Owner

pszufe commented Aug 29, 2021

so now we have here a conflict with an earlier PR - needs to be resolved.

@pszufe
Copy link
Owner

pszufe commented Aug 29, 2021

Looks fine to me. Again we have conflict. Perhaps the changes are quite atomic :-)

@blegat
Copy link
Contributor Author

blegat commented Aug 30, 2021

Yes, I don't mind rebasing, it's worth it to have small self-contained changes :)

@pszufe pszufe merged commit 85a2d03 into pszufe:master Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants