NetworkX

Previous topic

networkx.algorithms.shortest_paths.weighted.bidirectional_dijkstra

Next topic

networkx.algorithms.shortest_paths.weighted.bellman_ford

networkx.algorithms.shortest_paths.weighted.dijkstra_predecessor_and_distance

networkx.algorithms.shortest_paths.weighted.dijkstra_predecessor_and_distance(G, source, weight='weight')

Compute shorest path length and predecessors on shortest paths in weighted graphs.

Parameters :

G : NetworkX graph

source : node label

Starting node for path

weight: string, optional :

Edge data key corresponding to the edge weight

Returns :

pred,distance : dictionaries

Returns two dictionaries representing a list of predecessors of a node and the distance to each node.

Notes

The list of predecessors contains more than one element only when there are more than one shortest paths to the key node.