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

[DOCUMENTATION | DELAYED] Explanation about ShortestPathOneToMany #27

Open
magnushiie opened this issue Sep 15, 2022 · 1 comment
Open
Assignees
Labels
delayed Task for delayed work documentation Documentation question Further information is requested

Comments

@magnushiie
Copy link
Contributor

What is your docs question about? Ask it
I assumed ShortestPathOneToMany used some clever algorithmic trick (like unidirectional Dijkstra is able to calculate all targets for one source in one go). Now, having read the algorithm source code, it seems to be almost the same as executing ShortestPathOneOne for all targets in sequence. The only difference I can see is that it is reusing the data structures across iterations. Is it only about reducing allocations or is there some deeper optimization that I cannot spot?

What do you suggest?
Add a section to README about how ShortestPathOneToMany works and why it is faster.

Additional context
None

@magnushiie magnushiie added documentation Documentation question Further information is requested labels Sep 15, 2022
@LdDl
Copy link
Owner

LdDl commented Sep 15, 2022

There is no clever trick. This is all about just reducing amount of allocations as you noticed.

reusing the data structures across iterations

Yes. It's just used in relaxation functions and nothing special:

// ...
// cid - ID of queue for certain target node
if forwProcessed[temp] != cid || queryDist[temp] > alt {
  queryDist[temp] = alt
  prev[temp] = vertex.id
  forwProcessed[temp] = cid
  node := &bidirectionalVertex{
	  id:        temp,
	  queryDist: alt,
  }
  heap.Push(forwQ, node)
}
// ...

We are not planning to make section about this function currently, since it's not a big optimization (at all, lol).
When we have some really useful optimization we'll make docs for it for sure.

Marking this issue as delayed for now

@LdDl LdDl added the delayed Task for delayed work label Sep 15, 2022
@LdDl LdDl changed the title [DOCUMENTATION] Explanation about ShortestPathOneToMany [DOCUMENTATION | DELAYED] Explanation about ShortestPathOneToMany Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
delayed Task for delayed work documentation Documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants