def single_source_bellman_ford(G, source, target=None, cutoff=None, weight='weight'):
 if (source == target):
  return ({source: 0}, {source: [source]})
 weight = _weight_function(G, weight)
 paths = {source: [source]}
 return (_bellman_ford(G, [source], weight, paths=paths, cutoff=cutoff, target=target), paths)

def single_source_bellman_ford ( G , source , target = None , cutoff = None , weight = 'weight' ) : if ( source == target ) : return ( { source : 0 } , { source : [ source ] } ) weight = _weight_function ( G , weight ) paths = { source : [ source ] } return ( _bellman_ford ( G , [ source ] , weight , paths = paths , cutoff = cutoff , target = target ) , paths )
compute shortest paths and lengths in a weighted graph g .