code: def _accumulate_subset(betweenness, S, P, sigma, s, targets):
      delta = dict.fromkeys(S, 0.0)
      target_set = set(targets) - {s}
      while S:
          w = S.pop()
          if w in target_set:
              coeff = (delta[w] + 1.0) / sigma[w]
          else:
              coeff = delta[w] / sigma[w]
          for v in P[w]:
              delta[v] += sigma[v] * coeff
          if w != s:
              betweenness[w] += delta[w]
      return betweenness
  
file_path: networkx/networkx/algorithms/centrality/betweenness_subset.py
imports: import networkx
  from networkx.algorithms.centrality.betweenness import _add_edge_keys
  from networkx.algorithms.centrality.betweenness import _single_source_dijkstra_path_basic
  from networkx.algorithms.centrality.betweenness import _single_source_shortest_path_basic
label_desc: Use image node_id 3 for calling a global function with example usage: _accumulate_subset(betweenness, S, P, sigma, s, targets) and returns: betweenness