Skip to content

Instantly share code, notes, and snippets.

@vncsna
Last active March 19, 2021 18:32
Show Gist options
  • Save vncsna/4f76e1aaf4698321dcf9cb16b6a10e70 to your computer and use it in GitHub Desktop.
Save vncsna/4f76e1aaf4698321dcf9cb16b6a10e70 to your computer and use it in GitHub Desktop.
extract a degree sequence from an adjacency matrix
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