Repository navigation
Adding Notes on Multi-Target Shortest Path Queries - #8169
Conversation
dschult
left a comment
There was a problem hiding this comment.
This is really nice @amcandio Thanks very much!!
I don't see any typos. I guess we should use double-ticks for code symbols. And we should wrap lines to about 80 chars so the .rst file is easily readable without formatting.
I really like the simple description and the choice of example. :)
|
Thanks @dschult! I replaced the code symbols by math symbols, reduced the line-lenght (except for the numerated lists, where it breaks) and also added some details on how to recover the true distance. |
rossbar
left a comment
There was a problem hiding this comment.
This is an excellent addition to the docs @amcandio , thanks very much! There may be ways we can consider to increase visibility, e.g. adding references to this section to See Also portions of path-finding docstrings (at least those with target kwargs) but that can be addressed as needed/desired separately!
Summary
This is a follow up from discussion on #703. It adds documentation notes to the
shortest_paths.rstfile explaining how to perform multi-target shortest path queries in NetworkX using a sentinel node trick. While NetworkX does not currently provide a built-in method for computing the shortest path from a source to the nearest of several targets, the documented technique enables users to efficiently perform such queries using existing shortest path algorithms.Motivation
Multi-target queries—such as finding the nearest facility, emergency center, or pickup point—are common in real-world applications. This note provides guidance on how to implement these queries in NetworkX using an elegant and general approach.
Rendering
Validations
This test-case is passing and I can send in a separate PR to ease reviewing: