From 97e10f5c94019d06f6f32464b61d8f300c1404a5 Mon Sep 17 00:00:00 2001 From: Aric Hagberg Date: Fri, 14 Jan 2011 18:19:22 -0700 Subject: Use nx.utils version of cumulative_sum --HG-- extra : rebase_source : 1ef0e0c0d6c43037373b4ce2968c003bff6f3c6f --- networkx/algorithms/richclub.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'networkx') diff --git a/networkx/algorithms/richclub.py b/networkx/algorithms/richclub.py index 7f35cb35..2b380daa 100644 --- a/networkx/algorithms/richclub.py +++ b/networkx/algorithms/richclub.py @@ -69,15 +69,10 @@ def rich_club_coefficient(G, normalized=True, Q=100): def _compute_rc(G): # compute rich club coefficient for all k degrees in G - def cumulative_sum(numbers): - csum = 0 - for n in numbers: - csum += n - yield csum deghist = nx.degree_histogram(G) total = sum(deghist) # number of nodes with degree > k (omit last entry which is zero) - nks = [total-cs for cs in cumulative_sum(deghist) if total-cs > 1] + nks = [total-cs for cs in nx.utils.cumulative_sum(deghist) if total-cs > 1] deg=G.degree() edge_degrees=sorted(sorted((deg[u],deg[v])) for u,v in G.edges_iter() if u!=v) -- cgit v1.2.1