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
CH improve amount of created shortcuts #15
Comments
my implementation is using OSM-files. The factor of edges before and after contraction is around 2. |
Thanks for your comments! I am not sure if I fully understand what you mean, but these additional shortcuts can be prevented by sorting the pairs of incoming/outgoing edges at the contracted node by their weights (sort the pairs by the sum of the weights of their incoming and outgoing edge). Sorting them ensures that the necessary shortcuts are introduced first and then serve as witness paths (thus preventing) the unnecessary ones. Is that what you mean? Or do you think there is another way that does not require this sorting? It'd be certainly interesting to try this, yes, do you have an estimate how it affects preparation vs. query time?
You mean the number of shortcuts roughly equals the number of edges of the graph? Yes that is my experience as well (for OSM graphs). Do you have an estimate how much the optimization you suggested reduces the number of shortcuts? Or do you mean the optimization you mentioned reduces the number of shortcuts by a factor of two? That would be rather surprising to me I do not expect it to be so significant.
Yes that should be an easy way to improve preparation time. And of course yes if you feel like contributing some code do not hesitate to send a PR. But if not I will probably try this myself because I'm interested how this is going to turn out. |
I briefly tried this (simply commenting out the path building) and it looks like the preparation time is reduced by about 10% (not so bad). We only need to find a way to make the path building conditional, because in dijkstra.rs I would like to keep it for testing purposes. |
what I did: an extra flag which can be set wether you only want the costs or the whole path? not super pretty
|
yes in my case there can exist multiple ways between one node.
the factor is only the amount of edges before contraction and after it. sadly i do not know how much this reduces the amount of shortcuts compared to your solution. maybe there is a research paper for it. |
Yes, I did that here: 19acab2, but not entirely sure if this really gives a significant speed-up, maybe only on large graphs?
we should just try ;) |
i will try this later today |
Your code is quite clean, thanks to this i created this draft. Have a look at it. |
See discussion in #16. |
as seen here, the amount of shortcuts is not optimal.
The current approach as described in the original publication is creating shortcuts, if the contracting node is not part of the shortest path from previous neighbor to the next neighbor. As seen here this can lead to non perfect amount of shortcuts.
A "newer" approach is, to have a distinct set of previous neighbors and another distinct set with following neighbors. Then use Dijkstra and calculate the travel-costs. If the cost is equal to the cost from previous to contracting node to the following neighbor then the path from neighbor to neighbor is the optimal path. Therefore a new shortcut has to be created. Otherwise another better path is available and will create a shortcut in the future.
The path itself does not have to be fully resolved. Only the costs are important. Additional Improvement
i already did an implementation in rust, but with a different data-structure: link
maybe I find some time and could try implement it for your model. Is this wanted? Or do your prefer doing this yourself?
The text was updated successfully, but these errors were encountered: