code: def _dijkstra_multisource(
      G,
      sources,
      weight,
      pred=None,
      paths=None,
      cutoff=None,
      target=None,
  ):
      """Uses Dijkstra's algorithm to find shortest weighted paths
  
      Parameters
      ----------
      G : NetworkX graph
  
      sources : non-empty iterable of nodes
          Starting nodes for paths. If this is just an iterable containing
          a single node, then all paths computed by this function will
          start from that node. If there are two or more nodes in this
          iterable, the computed paths may begin from any one of the start
          nodes.
  
      weight: function
          Function with (u, v, data) input that returns that edge's weight
          or None to indicate a hidden edge
  
      pred: dict of lists, optional(default=None)
          dict to store a list of predecessors keyed by that node
          If None, predecessors are not stored.
  
      paths: dict, optional (default=None)
          dict to store the path list from source to each node, keyed by node.
          If None, paths are not stored.
  
      target : node label, optional
          Ending node for path. Search is halted when target is found.
  
      cutoff : integer or float, optional
          Length (sum of edge weights) at which the search is stopped.
          If cutoff is provided, only return paths with summed weight <= cutoff.
  
      Returns
      -------
      distance : dictionary
          A mapping from node to shortest distance to that node from one
          of the source nodes.
  
      Raises
      ------
      NodeNotFound
          If any of `sources` is not in `G`.
  
      Notes
      -----
      The optional predecessor and path dictionaries can be accessed by
      the caller through the original pred and paths objects passed
      as arguments. No need to explicitly return pred or paths.
  
      """
      G_succ = (
          G._adj
      )  # For speed-up (and works for both directed and undirected graphs)
  
      push = heappush
      pop = heappop
      dist = {}  # dictionary of final distances
      seen = {}
      # fringe is heapq with 3-tuples (distance,c,node)
      # use the count c to avoid comparing nodes (may not be able to)
      c = count()
      fringe = []
      for source in sources:
          seen[source] = 0
          push(fringe, (0, next(c), source))
      while fringe:
          (d, _, v) = pop(fringe)
          if v in dist:
              continue  # already searched this node.
          dist[v] = d
          if v == target:
              break
          for u, e in G_succ[v].items():
              cost = weight(v, u, e)
              if cost is None:
                  continue
              vu_dist = dist[v] + cost
              if cutoff is not None:
                  if vu_dist > cutoff:
                      continue
              if u in dist:
                  u_dist = dist[u]
                  if vu_dist < u_dist:
                      raise ValueError(
                          "Contradictory paths found:",
                          "negative weights?",
                      )
                  elif pred is not None and vu_dist == u_dist:
                      pred[u].append(v)
              elif u not in seen or vu_dist < seen[u]:
                  seen[u] = vu_dist
                  push(fringe, (vu_dist, next(c), u))
                  if paths is not None:
                      paths[u] = paths[v] + [u]
                  if pred is not None:
                      pred[u] = [v]
              elif vu_dist == seen[u]:
                  if pred is not None:
                      pred[u].append(v)
  
      # The optional predecessor and path dictionaries can be accessed
      # by the caller via the pred and paths objects passed as arguments.
      return dist
  
imports: from collections import deque
  from heapq import heappop, heappush
  from itertools import count
  import networkx
  from networkx.algorithms.shortest_paths.generic import _build_paths_from_predecessors
label_desc: Use image node_id 11 for calling a global function with example usage: _dijkstra_multisource(G, sources, weight, pred, paths, cutoff, target) and returns: dist