Skip to content

What is the difference between shortest_simple_paths and all_shortest_paths? #6381

Answered by dschult
TOMOFUMI-KONDO asked this question in Q&A
Discussion options

You must be logged in to vote

The function shortest_simple_paths yields all the simple paths in order of length. So most of the resulting paths are not "shortest paths". To explain the name, think of "I want the 6 shortest simple paths".

The function all_shortest_paths yields all of the possible shortest paths. All of these paths will have the same length. The use for this function is when there are multiple ways to go that are the same distance. Instead of just giving one example of a shortest path, this function provides them all.

Perhaps the docs should include a comparison of these functions... Anyone know if a paragraph be included in a Sphinx "See Also" section?

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@TOMOFUMI-KONDO
Comment options

Answer selected by rossbar
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants