def _accumulate_subset(betweenness,S,P,sigma,s,targets):
    delta=dict.fromkeys(S,0)
    target_set=set(targets)
    while S:
        w=S.pop()
        for v in P[w]:
            if w in target_set:
                delta[v]+=(sigma[v]/sigma[w])*(1.0+delta[w])
            else:
                delta[v]+=delta[w]/len(P[w])
        if w != s:
            betweenness[w]+=delta[w]
    return betweenness
dataset/ETHPy150Open gkno/gkno_launcher/src/networkx/algorithms/centrality/betweenness_subset.py/_accumulate_subset/original