def get_degrees(A):
    """
    Pre-computation for degree of each node in the adjacency matrix
    :param A: adjacency matrix
    :return: degrees for each node, 2 * number of edges
    """
    two_m = 0
    degree_list = [0] * A.shape[0]
    for processed, e in enumerate(A.items()):
        node1, node2 = e[0]
        degree_list[node1] += A[node1, node2]
        two_m += 1  # total num. of edges * 2
    return degree_list, two_m