code: def _accumulate_percolation(
      percolation, S, P, sigma, s, states, p_sigma_x_t
  ):
      delta = dict.fromkeys(S, 0)
      while S:
          w = S.pop()
          coeff = (1 + delta[w]) / sigma[w]
          for v in P[w]:
              delta[v] += sigma[v] * coeff
          if w != s:
              # percolation weight
              pw_s_w = states[s] / (p_sigma_x_t - states[w])
              percolation[w] += delta[w] * pw_s_w
      return percolation
  
imports: import networkx
  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 2 for calling a global function with example usage: _accumulate_percolation(percolation, S, P, sigma, s, states, p_sigma_x_t) and returns: percolation