def multi_source_dijkstra(G, sources, target=None, cutoff=None, weight='weight'):
 if (not sources):
  raise ValueError('sources must not be empty')
 if (target in sources):
  return ({target: 0}, {target: [target]})
 weight = _weight_function(G, weight)
 paths = {source: [source] for source in sources}
 dist = _dijkstra_multisource(G, sources, weight, paths=paths, cutoff=cutoff, target=target)
 return (dist, paths)

def multi_source_dijkstra ( G , sources , target = None , cutoff = None , weight = 'weight' ) : if ( not sources ) : raise ValueError ( 'sources must not be empty' ) if ( target in sources ) : return ( { target : 0 } , { target : [ target ] } ) weight = _weight_function ( G , weight ) paths = { source : [ source ] for source in sources } dist = _dijkstra_multisource ( G , sources , weight , paths = paths , cutoff = cutoff , target = target ) return ( dist , paths )
find shortest weighted paths and lengths from a given set of source nodes .