Skip to main content
`Ctrl`+`K`

# reconstruct_path

reconstruct_path(source, target, predecessors)

  Reconstruct a path from source to target using the predecessors dict as returned by floyd_warshall_predecessor_and_distance

  Parameters:
    source node

      Starting node for path

    target node

      Ending node for path

    predecessors: dictionary

      Dictionary, keyed by source and target, of predecessors in the shortest path, as returned by floyd_warshall_predecessor_and_distance

  Returns:
    path list

      A list of nodes containing the shortest path from source to target

      If source and target are the same, an empty list is returned

  See also

  `floyd_warshall_predecessor_and_distance`

  Notes

  This function is meant to give more applicability to the floyd_warshall_predecessor_and_distance function