Last active
March 19, 2021 18:32
-
-
Save vncsna/4f76e1aaf4698321dcf9cb16b6a10e70 to your computer and use it in GitHub Desktop.
extract a degree sequence from an adjacency matrix
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_sequence(graph): | |
'''Get a degree sequence of a graph. | |
Parameters: | |
graph: scipy.sparse.csr.csr_matrix | |
A graph in compressed sparse row format. | |
''' | |
degree_seq = graph.sum(axis=0).A.ravel() | |
return degree_seq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment