Note
This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.
rustworkx.graph_all_shortest_paths#
- graph_all_shortest_paths(graph, source, target, /, weight_fn=None, default_weight=1.0)#
Find all shortest paths between two nodes
This function will generate all possible shortest paths from a source node to a target using Dijkstra’s algorithm.
- Parameters:
graph (PyGraph) –
source (int) – The node index to find paths from
target (int) – A target to find paths to
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_fn
isn’t specified this optional float value will be used for the weight/cost of each edge.
- Returns:
List of paths. Each paths are lists of node indices, starting at
source
and ending attarget
.- Return type:
list
- Raises:
ValueError – when an edge weight with NaN or negative value is provided.