def dijkstra_path(G, source, target, weight='weight'):
 (length, path) = single_source_dijkstra(G, source, target=target, weight=weight)
 try:
  return path[target]
 except KeyError:
  raise nx.NetworkXNoPath(('node %s not reachable from %s' % (target, source)))

def dijkstra_path ( G , source , target , weight = 'weight' ) : ( length , path ) = single_source_dijkstra ( G , source , target = target , weight = weight ) try : return path [ target ] except KeyError : raise nx . NetworkXNoPath ( ( 'node %s not reachable from %s' % ( target , source ) ) )
returns the shortest weighted path from source to target in g .