def calculate_degrees(matrix):
    """Determines the outward and inward degrees of a matrix"""
    out_degree = (matrix * matrix.T).diagonal()
    in_degree = (matrix.T * matrix).diagonal()
    return out_degree, in_degree