summaryrefslogtreecommitdiff
path: root/networkx
diff options
context:
space:
mode:
authorAric Hagberg <aric.hagberg@gmail.com>2011-01-14 18:19:22 -0700
committerAric Hagberg <aric.hagberg@gmail.com>2011-01-14 18:19:22 -0700
commit97e10f5c94019d06f6f32464b61d8f300c1404a5 (patch)
tree59ae434dcea621f71e5a6e3687e625a0a15a1722 /networkx
parentcb10ee91c2cecae60f5b99282d0da31b628dbbc2 (diff)
downloadnetworkx-97e10f5c94019d06f6f32464b61d8f300c1404a5.tar.gz
Use nx.utils version of cumulative_sum
--HG-- extra : rebase_source : 1ef0e0c0d6c43037373b4ce2968c003bff6f3c6f
Diffstat (limited to 'networkx')
-rw-r--r--networkx/algorithms/richclub.py7
1 files changed, 1 insertions, 6 deletions
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)