code: def _accumulate_edges_subset(betweenness, S, P, sigma, s, targets):
      """edge_betweenness_centrality_subset helper."""
      delta = dict.fromkeys(S, 0)
      target_set = set(targets)
      while S:
          w = S.pop()
          for v in P[w]:
              if w in target_set:
                  c = (sigma[v] / sigma[w]) * (1.0 + delta[w])
              else:
                  c = delta[w] / len(P[w])
              if (v, w) not in betweenness:
                  betweenness[(w, v)] += c
              else:
                  betweenness[(v, w)] += c
              delta[v] += c
          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 4 for calling a global function with example usage: _accumulate_edges_subset(betweenness, S, P, sigma, s, targets) and returns: betweenness