Skip to content

Instantly share code, notes, and snippets.

@vncsna
Last active March 19, 2021 18:31
Show Gist options
  • Save vncsna/039721505c4caa31cbe94e83d14a28c3 to your computer and use it in GitHub Desktop.
Save vncsna/039721505c4caa31cbe94e83d14a28c3 to your computer and use it in GitHub Desktop.
extract a degree distribution from a degree sequence
def get_degree_distribution(degseq):
'''Get a degree distribution of a graph.
Parameters:
degseq: numpy.ndarray
A sequence of degrees.
'''
degree, frequency = np.unique(degseq, return_counts=True)
distribution = frequency / frequency.sum()
return distribution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment