The following is my code:
import numpy as np import cvxpy as cp from itertools import product threshold = lambda A,n: np.clip(A, 0, n) def edge_entropy(A, r