Last active
March 19, 2021 18:31
-
-
Save vncsna/039721505c4caa31cbe94e83d14a28c3 to your computer and use it in GitHub Desktop.
extract a degree distribution from a degree sequence
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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