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

Allow multiple sources in distance_field #27

Closed
tvercaut opened this issue Aug 5, 2021 · 5 comments · Fixed by #28
Closed

Allow multiple sources in distance_field #27

tvercaut opened this issue Aug 5, 2021 · 5 comments · Fixed by #28
Labels

Comments

@tvercaut
Copy link

tvercaut commented Aug 5, 2021

In some scenarios, it might be interesting to get a distance field for multiple source.

The networkx library for example provides such a functionality for general graphs:
https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.weighted.multi_source_dijkstra_path_length.html

I am not sure how this could best be implemented in dijkstra3d but I believe a classical "trick" is choose (for example) the first source as "the source" and use a single-source implementation but make sure that all other "secondary sources" are connected to the first source with a zero-weight edge.

@william-silversmith
Copy link
Contributor

For dijkstra3d, it would be simple to just insert the multiple sources into the priority queue at the start and proceed normally. The zero edge weight trick won't work in dijkstra3d unless the sources are all adjacent to each other due to the implicit graph structure.

@william-silversmith
Copy link
Contributor

@tvercaut I have a prototype of this functionality ready. If you have a use case for it, give it a shot and let me know how it goes.

@william-silversmith
Copy link
Contributor

Multi-source is now enabled in 1.10.0 give it a shot!

@tvercaut
Copy link
Author

tvercaut commented Aug 6, 2021

Brilliant, thanks!
I have updated my quick notebook to reflect it:
https://colab.research.google.com/drive/196EPtBO0BmIjYmi6RlBvLlD_JGyAE9zB?usp=sharing

I get qualitatively similar results than with networkx for either single or muli-source distance maps but get numerical differences. I guess this is just related to an inconsistent definition of the graph structure between my networkx manual definition and the implicit one from dijkstra3d as I have not cleanly defined the forward and backward edges. I was indeed initially looking for an undirected graph with an edge weight as per #26

@william-silversmith
Copy link
Contributor

I was trying to play around with your python notebook but for some reason was running into problems with installing dijkstra3d. Are you running into the same problem? I tried releasing a new version that is compiled against oldest-supported-numpy to deal with the binary compatibility issue but it seems not to be working on the notebook. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants