The documentation for retworkx has migrated to:
These docs will no longer be updated.
Find the shortest path from a node
This function will generate the shortest path from a source node using Dijkstra’s algorithm.
graph (PyDiGraph) –
source (int) – The node index to find paths from
target (int) – An optional target path to find the path
weight_fn – An optional weight function for an edge. It will accept a single argument, the edge’s weight object and will return a float which will be used to represent the weight/cost of the edge
default_weight (float) – If
weight_fnisn’t specified this optional float value will be used for the weight/cost of each edge.
as_undirected (bool) – If set to true the graph will be treated as undirected for finding the shortest path.
Dictionary of paths. The keys are destination node indices and the dict values are lists of node indices making the path.
- Return type