Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality to statistics.py #47

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
Updated clustering by degree api.
tlarock committed Mar 26, 2019
commit e711d19bf915ba532974c5fe2658fac67c365c98
20 changes: 13 additions & 7 deletions pathpy/algorithms/statistics.py
Original file line number Diff line number Diff line change
@@ -287,7 +287,7 @@ def degree_dist_binned(network, num_bins=30, degree='degree', log_bins=True, is_
return x, p


def clustering_by_degree(network, num_bins=20, degree='degree', log_bins=False):
def clustering_by_degree(network, num_bins=20, degree='degree', binned=True, log_bins=False):
'''
Compute binned clustering by degree.

@@ -325,13 +325,19 @@ def clustering_by_degree(network, num_bins=20, degree='degree', log_bins=False):

## Get degrees
degrees = _np.array(list(degrees_dict.values()))
degrees = degrees[degrees>0]

## Get bins
bins = get_bins(degrees, num_bins, log_bins)
start = bins[:-1]
end = bins[1:]
center = start + (end-start)*0.5
if binned:
degrees = degrees[degrees>0]
## Get bins
bins = get_bins(degrees, num_bins, log_bins)
start = bins[:-1]
end = bins[1:]
center = start + (end-start)*0.5
else:
bins = _np.unique(degrees)
start = bins[:-1]
end = bins[1:]
center = start + (end-start)*0.5

cc_k = dict((k,0.0) for k in range(len(center)))
counts = dict((k,0.0) for k in range(len(center)))